Java Reference
In-Depth Information
This method can then be called on the
arguments
object using the
call
method:
slice.call(arguments, 1, 3)
The
call
method takes the object that the function is to be applied to as its first argument,
and then the usual arguments come afterwards.
This can also be done directly from an array literal like so:
[].slice.call(arguments, 1, 3)
If you are finding that you need to call a lot of array methods on an array-like object, it
might be worth turning it into an array using the
slice
method with no arguments:
Array.prototype.slice.call(arguments);
<<
This will return the
arguments
object as an array (since the
slice()
method returns
an array).
