The use of js call apply

I"m learning in js. One practical application of call and apply,call is to convert an array of classes into an array. I have a question, why go to the slice method on the call array Array prototype, I took a look at slice"s api, and I want to ask why I use this method on Array.prototype?

 function fun(){
    var argArr = Array.prototype.slice.call(arguments);
    debugger
 }
 fun(1,3,5,9)

one more question, what is the principle of [] .slice.call (arguments) that is the same as the Array.prototype.slice.call (arguments) result?

Apr.21,2021

because arguments is just a class array, not an array, there is no slice method, which is intended to return a new array with slice .

for supplementary questions, first of all, [] itself does not have slice , so look for slice on the prototype chain, and then he is a Array , so he finds that the two sentences Array.prototype.slice are the same.

Menu