Array.prototype.slice.call(arguments)

Array.prototype.slice.call(arguments)能够将具有length属性的对象转化为数组,

可以理解为将arguments转化成一个数组对象,让它具有slice方法

如:

function test(){
    console.log(Array.prototype.slice.call(arguments));
}
test(1,2);

Array是一个类,不能直接引用,需要获取原型后才能使用。

如果要直接引用,需要实例化array

var array = new Array();

array.slice.call(arguments);

array.slice(start,end)

console.log([1,2,3].slice());
//[1, 2, 3]
console.log([1,2,3].slice(1,3));
//[2, 3]

call的作用是改变this的指向,相当于arguments调用了slice这方法

原文地址:https://www.cnblogs.com/tianxinyu/p/6165001.html