MV .isWTypeEquipped & .equips()[]

I was wondering if it was possible to make a statement that checks if a certain equipment slot (such as .equips(1)[]) contains a certain weapon type equipped? Also, what's the script call to forcibly unequip something from a specific slot?
Could you use a little more elaboration but I think this is what you want

JavaScript:
 $gameActors.actor(actorId).equips().forEach(function(e){

    if(e.isWtypeEquipped(ID OF WEAPON TYPE)){
     // do whatever
    }

})

and for your other question

$gameActors.actor(actorId).changeEquip(slotId, item);

just set the slot id to 0 to remove the equip
JavaScript:
$gameActors.actor(actorId).equips().forEach(function(e){

    if(e.isWtypeEquipped(ID OF WEAPON TYPE)){
     // do whatever
    }

})
If I only want it to check slot 1, would it look like this?...
JavaScript:
$gameActors.actor(actorId).equips()[1]{

    if(e.isWtypeEquipped(ID OF WEAPON TYPE)){
     // do whatever
    }

})
Edit: No wait, that's not right...I need to retain "function(e)" don't I? But I don't want it to check the whole array (aka "forEach"), just a single slot.
The first slot would be 0, and if you only want to check the first slot then you can do something like

JavaScript:
var e = $gameActors.actor(actorId).equips()[0]

if (e.isWtypeEquipped(ID OF WEAPON TYPE)) {

    // do whatever

}
isWTypeEquipped is a method of Game_Actor that loops through that actor's equipped weapons and checks each of them for the specified weapon type:
Spoiler: Game_Actor > isWTypeEquipped (rpg_objects.js)
JavaScript:
Game_Actor.prototype.isWtypeEquipped = function(wtypeId) {
    return this.weapons().some(function(weapon) {
        return weapon.wtypeId === wtypeId;
    });
};
In this case it sounds like you just want to check one weapon: you can use something like this in a scripted if or via Conditional Branch > Script, e.g.
JavaScript:
var w = $gameActors.actor(1).weapons()[0]; w ? w.wtypeId === 5 : false
I.e. "let w equal actor 1's first weapon; if the weapon exists, return true iff it is of type 5, else return false". You can reference weapon types via the Types tab in the database.

For changing equipment, note that changeEquip expects item arguments; 0 works here because JavaScript treats it as falsy, but the standard "empty slot object" used in the core scripts is null. An alternative is changeEquipById:
JavaScript:
$gameActors.actor(1).changeEquipById(1, 0);
I.e. "equip item ID 0 (i.e. null) in equip slot 1 (first type, by default a weapon)". You can reference equipment types via the Types tab in the Database.

Original thread: https://forums.rpgmakerweb.com/threads/iswtypeequipped-equips.129489/