Here's the code snippet first, I'll deconstruct it in a moment.
this.argArr = [['arg1', 'arg2'], ['foo', 'bar'], ['you get ', 'the point']];
this.evalArgsFromArr = function () {
var out = [];
for (var _ = 0; _ < parent.argArr.length; _++) {
out.push(someFunction(...parent.argArr[_])); // This part crashes
}
return out;
};
This function is part of an object, of course.
The idea is that, each item in parent.argArr
should be an array, containing two arguments for someFunction()
, which also handily serve as a human-readable condensation of the output. My understanding is, used on an iterable object (such as the arrays stored in parent.argArr
), the spread operator outputs each individual value separately. (For example, the first run of the for
loop should output someFunction('arg1', 'arg2')
.)
Whenever I run a file containing this in Node.js or PHP I get a SyntaxError: Unexpected token, citing the spread operator [...
].
Here's the error message, if it helps:
I'm using Node 7.8.0.