push返回数组新长度,改变原数组
pop返回该元素;如果数组为空,返回undefined,改变原数组
shift删除第一个元素并返回该元素,改变原数组
unshift添加到数组头部并返回数组新长度,改变原数组
filter((currentValue, index, array)=>{})创建一个新数组
forEach((currentValue, index, array)=>{})创建一个新数组
map((currentValue, index, array)=>{})创建一个新数组
every((currentValue, index, array)=>{})数组内是否所有元素都能通过回调函数,返回bool值
some((currentValue, index, array)=>{})数组内至少有一个元素通过了回调函数,返回bool值
find((currentValue, index, array)=>{})返回通过回调函数的第一个元素
flat(depth?)按照指定的深度递归遍历数组,并将所有元素与子元素合并成为一个新数组返回,不改变原数组,默认值为1
返回一个新数组,其结果是该数组中每个元素回调后的返回值
sort
reverse
delete删除元素后,会把该下标的值置为undefined,数组长度不变
slice(startIndex, endIndex)
截取数组元素,不会改变原数组,返回一个新数组。如果不传入endIndex,则截取到数组尾部。
splice(index, len, [item])会改变原数组
splice既可以删除元素,也可以添加/替换元素,只是参数不同罢了
删除时,splice(index, len),设置删除的起始下标和删除的长度,不设置[item]。
添加时,splice(index, 0, [item]),添加时长度固定为0。
替换时,splice(index, len, [item])