1. 扁平化处理
2. 类数组转化成数组
3. 将一组值,转换为数组
4. ES6
- copyWithin()
- find() 和 findIndex()
- fill
- entries(),keys() 和 values()
- includes()
- flatMap()
空位
数组的空位指,数组的某一个位置没有任何值。比如,Array 构造函数返回的数组都是空位,空位不是 undefined 。
Array(3) // [, , ,]
forEach(),filter(),reduce(),every()和some()都会跳过空位。map()会跳过空位,但会保留这个值join()和toString()会将空位视为undefined,而undefined和null会被处理成空字符串。Array.from方法会将数组的空位,转为undefined,也就是说,这个方法不会忽略空位。- 扩展运算符(...)也会将空位转为
undefined。 entries()、keys()、values()、find()和findIndex()会将空位处理成undefined。for...of循环也会遍历空位。fill()会将空位视为正常的数组位置。copyWithin()会连空位一起拷贝。