That is a type of array destructuring and can be used to pass the elements of an array to a function.
const array = [ 4, 2 ]; const sixteen = Math.pow(...array);
is equivalent to
const sixteen = Math.pow(4, 2); // or const sixteen = Math.pow(array[0], array[1], /* ... */);
yeah, but in a component model, when handling functions, it becomes black box
passToAnotherFunc() { handleItSomewhere(...arguments); }
now, I completely unaware of the argument list!
the value of arguments here is the value of the arguments passed to passToAnotherFunc. See the deprecated arguments object
arguments
passToAnotherFunc
Wait, the arguments isn't deprecated, it's only arguments.caller property that's non-standard and deprecated.
arguments.caller
Combining Meghan's two earlier responses, a better way would be:
passToAnotherFunc(...args) { handleItSomewhere(...args); }
But I feel it's unlikely you'd need to write this kind of code. Could you give a real-world example?
@antjanus it's not deprecated per-se but it is disabled in strict and module mode.
@shalvah +1 because instead of calling passToAnotherFunc to call handleItSomewhere, why not just call handleItSomewhere?
handleItSomewhere
I had no idea it was disabled in strict/module mode!
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
That is a type of array destructuring and can be used to pass the elements of an array to a function.
is equivalent to
yeah, but in a component model, when handling functions, it becomes black box
now, I completely unaware of the argument list!
the value of
arguments
here is the value of the arguments passed topassToAnotherFunc
. See the deprecated arguments objectWait, the
arguments
isn't deprecated, it's onlyarguments.caller
property that's non-standard and deprecated.Combining Meghan's two earlier responses, a better way would be:
But I feel it's unlikely you'd need to write this kind of code. Could you give a real-world example?
@antjanus it's not deprecated per-se but it is disabled in strict and module mode.
@shalvah +1 because instead of calling
passToAnotherFunc
to callhandleItSomewhere
, why not just callhandleItSomewhere
?I had no idea it was disabled in strict/module mode!