总结总结数组面试小题目常用函数;
1,map()
array.map(function(currentValue, index, arr), thisIndex)
map()不会对空数组进行检测
map()不会改变原始数组
1.currentValue:必须。当前元素的的值。 2. index:可选。当前元素的索引。 3. arr:可选。当前元素属于的数组对象。
2,splice(start,删几个,加什么 )
3,slice(start);深拷贝
4,基础push(),shift() unshift(),pop()
5,forEach()
let arr = [1, 2, , 3]
arr.forEach((item, index) => {
console.log(`arr[${index}] = ${item}`)
})
6.concat 连接数组
return arr1.concat.(arr2);