MV Help! $gameVariables.value(...).equals is not a function

So I have been playing around with an evented cooking system and for some reason this error pops up. I'm not sure as to why it's not working. Any help would be really appreciated...
Your first blue line should be $gameVariables.value(4)==[0,0,0]

I'm not even sure if that will work but you can try it

All the blue lines need to be in that format
JavaScript arrays don't have an equals method. A simple equality check won't work either, because that operates by reference for non-primitives, and each Array is a new object. You'd need to check each value individually.

I think something like this would work:
JavaScript:
var a = [0,0,0]; $gameVariables.value(4).every(function(v, n) { return v === a[n]; });

[Edit: actually that's unlikely to be the problem, see Trihan's reply.]
i was going to suggest something along the lines of
Code:
JSON.stringify($gameVariables.value(4))==JSON.stringify([0,0,0])
, but the main point was covered. equals isnt an array function
JavaScript arrays don't have an equals method. A simple equality check won't work either, because that operates by reference for non-primitives, and each Array is a new object. You'd need to check each value individually.

I think something like this would work:
JavaScript:
var a = [0,0,0]; $gameVariables.value(4).every(function(v, n) { return v === a[n]; });
You're actually incorrect; rpg_core.js adds Array.prototype.equals.

I think the issue here may be that the variable doesn't contain an array at the time it's trying to run the function.
Array.prototype.equals works on my end. I intentionally left off a bracket and I got a similar error as yours. Double check your syntax. It would at least return false if variable 4 was some kind of array.

There should be enough time for it to see it as an array so my current guess is that you may be missing a parenthesis or square bracket in your assignment of the variable 'array'.
equalsarray.png

Edit:
Also, when using .sort(), you don't need to re-assign it. You should just be able to do (edit: caethyril is correct though, assigning it should be just fine if you are using var - const will give you an error if you tried to assign something else to it I think):
equalsarray2.png
@Trihan - oh, neat! And it's in MZ too.

Yea, in that case the variable probably hasn't been initialised correctly. Which seems strange because I don't see anything obviously wrong with the script call immediately before it, which sets the value.

@bass2yang - just tried that and a syntax error crashes the game at the Script command, rather than at Conditional Branch (command111). Maybe OP is using a plugin that makes such errors silent, though.

Per spec, Array#sort returns the sorted array, so what they have should be OK in that respect.

@Noonyons - ideas:
  1. Copy+paste that entire script call here so people can check it for errors?

  2. Are you certain this is the event being activated, e.g. switch 3 is on & there are no similar events?

  3. Turn off all plugins, save your project to apply Plugin Manager changes, then test. If that fixes it, consider sharing a screenshot of your Plugin Manager.

  4. Press F8 during playtest to show the dev tools window, go to the Console tab, and type this:

    [].equals
    Press Enter and it should show some function code. If it shows undefined instead, then something strange is going on. 😅

  5. Spoiler: Check your editor and project versions
    • Editor version: Help -> About.
    • Core script version: Game -> Open Folder, then check the first couple of lines of js/rpg_core.js in a text editor, e.g.

      //============================================================================= // rpg_core.js v1.6.2
    Generally these versions should match, but 1.6.2 is the most recent official core script update (and I'm not sure if anything actually changed from 1.6.1 to 1.6.2).

    If necessary, instructions for updating your core scripts can be found here:
    The announcement is for 1.6.1, but it's the same idea for all versions.
So i tried turning off all the plugins and it still caused an error. I started a new project and for some reason it worked there. I don't know why, but yah. It's sorta fixed like that

Original thread: https://forums.rpgmakerweb.com/threads/help-gamevariables-value-equals-is-not-a-function.168383/