Array.prototype.slice.call(arguments, 1)
可以理解成是让arguments
转换成一个数组对象,让arguments
具有slice()
方法Array.prototype.slice.call(arguments)
能将具有length
属性的对象转成数组,除了IE
下的节点集合(因为ie
下的dom
对象是以com
对象的形式实现的,js
对象与com
对象不能进行转换)
var a={length:2,0:'first',1:'second'};
console.log(Array.prototype.slice.call(a,0));
var a={length:2,0:'first',1:'second'};
console.log(Array.prototype.slice.call(a,1));
var a={0:'first',1:'second'};
console.log(Array.prototype.slice.call(a,0));
function test(){
console.log(Array.prototype.slice.call(arguments,0));
console.log(Array.prototype.slice.call(arguments,1));
}
test("a","b","c");