js数组

1.splice

splice() 方法向/从数组中添加/删除项目,然后返回被删除的项目。

该方法会改变原始数组。

2.slice

slice() 方法可从已有的数组中返回选定的元素。

该方法并不会修改数组,而是返回一个子数组。

3.Array.prototype.slice.call(arguments)

将具有length属性的对象转成数组。

1 var a={length:2,0:'first',1:'second'};
2 Array.prototype.slice.call(a);//  ["first", "second"]
3  
4 var a={length:2};
5 Array.prototype.slice.call(a);//  [undefined, undefined]

4.arguments

arguments 是一个对应于传递给函数的参数的类数组对象。

arguments对象是所有(非箭头)函数中都可用的局部变量。不是一个 Array 。它类似于Array,但除了length属性和索引元素之外没有任何Array属性。

arguments 是一个对应于传递给函数的参数的类数组对象。

原文地址:https://www.cnblogs.com/jiktiv123/p/7884535.html