What is more puzzling is that sincearrIs an array, why not write it like this directly
Why does the instance object itself already have this method, and why does it not call directly and use this method instead? Is there any special purpose?
Convert to an array object:console.log(Array.prototype.slice.call(foo,0)); //["hello", "world"] console.log(foo.slice()) //["hello", "world"]
This is because this array-like object has this slice method. What if it doesn’t? Can’t use directly, to use the prototype method calls. As follows:console.log(Array.prototype.splice.call(foo,0)); //["hello", "world"] console.log(foo.splice()) //TypeError: Object #<Object> has no method 'splice'
The commonly used arguments objects, document.links, document.forms, etc. are all very like Arrays, which can be converted into array operations by using Array.prototype.slice.call