Given the following code:
/*jslint white:true, devel:true*/
var foo = function () {
'use strict';
console.log(
Array.prototype.slice.call(
/* How can I send more arguments to call after 'arguments'? */
arguments,
/*
This function gets sent to slice.
If I sent a '2' it would start the array at the third index.
*/
function () {
console.log("bar");
}
)
);
};
foo(1, 2, 3, 4, 5, 6);
I am trying to better understand how the parameters work in this context. It seems that the second parameter is always sent to slice.
Is there any way to send another parameter to call in this context? Or would I need to rewrite the code to .slice()
separately from the .call()
?
UPDATE:
I am not really sure why this was down-voted. My conceptual misunderstanding was that .slice
was taking over, rather than being passed all arguments through .call()
. Thanks to Quentin for clarifying it.