Array.prototype.slice.call(arguments)可以将具备length属性的对象转化为数组,数组
能够理解为将arguments转化成一个数组对象,让它具备slice方法this
如:spa
function test(){ console.log(Array.prototype.slice.call(arguments)); } test(1,2);
Array是一个类,不能直接引用,须要获取原型后才能使用。prototype
若是要直接引用,须要实例化arraycode
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这方法blog