Currently, I am diving into the MDN Article regarding the slice
method in JavaScript. With everything making sense except for the 2nd example found under the section labeled Array-Like Objects.
In that particular example, it mentions simplifying the initial case by creating our own version of slice
as shown below:
var unboundSlice = Array.prototype.slice;
var slice = Function.prototype.call.bind(unboundSlice);
function list() {
return slice(arguments);
}
var list1 = list(1, 2, 3); // [1, 2, 3]
The point of confusion arises from the fact that call
appears directly after prototype
on the second line.
Usually, we see it structured more like
Array.prototype.slice.call(arguments)
or something along those lines.
The intricacies of how the first two lines interact to ultimately create a functioning slice
function elude me at the moment.