对原数组进行操作
Array.prototype.reverse()
myArray.reverse();
复制代码
Array.prototype.shift()
myArray.shift();
复制代码
Array.prototype.unshift()
myArray.unshift(element1, ..., elementN);
复制代码
Array.prototype.splice()
myArray.splice(start, deleteCount, item1, item2, ...);
复制代码
String.prototype.split()
var newArray=str.split([separator[, limit]]);
复制代码
返回新数组,不改变原数组
Array.prototype.slice()
var newArray=array1.slice(begin, end);
复制代码
Array.prototype.concat()
var newArray=array1.concat(array2); //array1在前
复制代码
Array.prototype.filter()
var newArray=array1.filter(value => value >= 10);
复制代码
Array.prototype.map()
var newArray = array1.map( x => x ** 2)
复制代码
Array.prototype.reduce()
var number=array1.reduce((accumulator, currentValue) => accumulator + currentValue)
复制代码
Array.prototype.join()
var string=array1.join();
复制代码
Array.prototype.reduce()
var number=array1.reduce((accumulator, currentValue) => accumulator + currentValue);
复制代码
Array.prototype.indexOf()
var num=array1.indexOf(searchElement[, fromIndex = 0]) //没有找到返回-1,找到返回索引
复制代码
mozilla