1
temp = {0:'one', 1:'two', 2:'three', 3:'four',length:4};
console.log(Array.prototype.slice.call(temp, 1));
//["two", "three", "four"]
这是为什么? length
属性在哪里?当Array.prototype.slice.call(temp, 1)
被调用时,它不应该是["two", "three", "four", 4]
吗?我无法理解Array.prootype.slice.call
slice()仅复制所调用对象的数字键后返回新数组。数组有一个.length属性,所以temp.length会告诉你它的长度。 – nnnnnn