Javascript中什么是伪数组?如何将其转化为标准数组?

2017-02-01  本文已影响0人  王康_Wang
var a = new Array(1,2,3,4,5);
console.log(a); //[1, 2, 3, 4, 5]
console.log(a.slice(1,2));//2
console.log(a.slice(1,-1));//[2, 3, 4]
console.log(a.slice(3,2));//[]
console.log(a); //[1, 2, 3, 4, 5]
console.log(a.slice());//[1,2,3,4,5]
function transform(a,b,c) {
  var newArr = Array.prototype.slice.call(argument);
  return newArr;
}
上一篇下一篇

猜你喜欢

热点阅读