Variables in scripting are confusing

I don't know if I'm doing it wrong or what, but I just cannot get them to work.
Here are some examples that do not work (They all had their numbers set before and these work completely fine if I replace the variable with a number) :

Code:
this._params = [$gameVariables.value(1)];
this.command119();

Code:
var byte = $gameVariables.value(7)

if ($gameActors.actor(byte).hasWeapon(1))
{
$gameMessage.add("test");
}

And here are examples where it DOES work:

Code:
var Bon = $gameActors.actor(2);
var random = $gameVariables.value(1);

Bon.forceAction(random, -2);
BattleManager.forceAction(Bon);
interpreter.setWaitMode('action');

Code:
var all = $gameVariables.value(1);

$gameParty.members(6).forgetSkill(all);

Update: I got the first one to work by adding ".toString()" to the end of the variable.
Update 2: I made more progress on the second:
Code:
var partymember = $gameActors.actor( $gameVariables.value(7).toString() );
if (partymember.weapons.include?($data_weapons[1, include_equip?]))
{
$gameMessage.add("test");
}
but it gives a syntax error for the ]
update 3: i replaced ".include?" with ".includes" and it works now!
Update: I got the first one to work by adding ".toString()" to the end of the variable.
the command119() command expects a string and does a strict comparison within itself. even though JS lets you get away with comparisons between numbers and numerical strings, a strict comparison immediately fails if the datatypes arent the same. you have to ensure that the value of that variable is a string, or use toString() as you did to pass its value as one
Spoiler: c119
1729415366562.png

var byte = $gameVariables.value(7) if ($gameActors.actor(byte).hasWeapon(1)) { $gameMessage.add("test"); }
the hasWeapon() function requires a actual $dataWeapon reference. not just a weapon id.

Spoiler
1729415632986.png
the weapons() array is a collection of weapons, not their ids

var all = $gameVariables.value(1); $gameParty.members(6).forgetSkill(all);
not an issue, but just a general tip. if youre going to make a variable and youre only going to use it once, you save yourself time and a posible mistake just using what would have been its value.
Code:
$gameParty.members(6).forgetSkill($gameVariables.value(1));
In addition to what @Robro33 pointed out, at least half of this line appears to be ripped from Ruby, it's not close to correct JavaScript syntax.

1729451459518.png

Original thread: https://forums.rpgmakerweb.com/threads/variables-in-scripting-are-confusing.172687/