1.扩展运算符(…)
合并数组:
//ES5 [1,2].concat(more)
//ES6 [1,2,...more]
2.对象转换成数组
Array.form (参数1:对象,参数2:function)
3.Array.of ()
将一组数值转换成数组
4..copyWithin()
将数组内指定位置的成员复制到其他位置,并修改当前数组
[1, 2, 3, 4, 5].copyWithin(0,3) //[4, 5, 3, 4, 5]
5..find、.findIndex
对数组内部进行条件查找
//find 返回符合条件的第一个数组成员
[1, 2, 3, 4, 5, 6].find((n) => n > 2) //3
//findIndex 返回第一个符合条件的数组成员位置,全部不符合,则返回-1
[1, 2, 3, 4, 5, 6].findIndex((n) => n > 2) //2
6..fill()
数组填充
['a', 'b', 'c'].fill(7,1,2)
//['a', 7, 'c']
7..includes()
检测某个数组是否包含指定值,返回布尔值(indexOf返回位置)
8.filter()
返回符合条件的所有元素
9..entries()、.keys()、 .values()
10.forEach()、map()
11.every()
检测数组的所有元素是否都符合条件;some()
检测数组是否有符合条件的元素