ScriptCraft

ScriptCraft

14.6k Downloads

myarray.includes is not a function

leumasme opened this issue ยท 4 comments

commented
myarray = new Array;
myarray.push("pls","send","help");
myarray.includes("pls");
->myarray.includes is not a function[...]

Tested same thing in Browser AND NodeJS, works fine

commented

+1 What @Gloorf said. includes is an ES6 function. ScriptCraft depends on the Javascript engine provided by the Java Runtime. Right now, Java doesn't have full support for ES6 (the latest version of Javascript) so some functions and features of ES6 will be missing.

commented

missclick

commented

found a workarround by adding
Array.prototype.includes = function(t){return this.indexOf(t)!="-1"}
to the start of the file to manually re-add the function of .includes, still think this should be fixed

commented

Array.prototype.includes is an ECMASCript6 feature ; ES6 support in nashorn (java's JS engine) can be found (partially, it seems not everything is supported yet) in java 9. See here for more informations