arr) [20,30,40]
6 slice() 查找数组中选定范围的值 返回值是一个数组 不会改变原来的数组
该方法有两个参数 slice( start , end )...console.log(arr2) // [30,40]
console.log(arr3) // [10,20]
7 splice() 方法用于添加或删除数组中的元素 会改变原来的数组...splice( index , howmany ) 该方法有两个必填参数
参数 1 index表示从什么位置开始添加或删除数组元素
参数 2 howmany 表示删除的元素数量,如果为...if (item >= 20) {
return item
}
})
console.log(arr2) // [20, 30, 40]
15 flat() 方法会按照一个可指定的深度递归遍历数组...方法最基本的作用就是数组降维
var arr1 = [1, 2, [3, 4,5,[6,7]];
arr3.flat(Infinity); // [1,2,3,4,5,6,7]