function destroyer(arr) {
}
destroyer([3, 5, 1, 2, 2], 2, 3, 5);
How would I access the values outside of the array? In this case the 2, 3, and 5. Thanks
function destroyer(arr) {
}
destroyer([3, 5, 1, 2, 2], 2, 3, 5);
How would I access the values outside of the array? In this case the 2, 3, and 5. Thanks
And how would I access them?
arguments[0] // [3, 5, 1, 2, 2]
arguments[1] // 2
As arguments is not array, but array-like object, you can’t use array’s method like slice.
To convert arguments to array, use
var args = Array.prototype.slice.call(arguments);
To get all arguments except first one using slice method:
var args = Array.prototype.slice.call(arguments, 1);