1、数组去重ES6写法
Set()
// 数组去重
let arr = [1,2,4,6,3,2,6,7,7,2,9,0,1,5]
arr = [...new Set(arr)]
console.log(arr);
2、数组去除指定值
filter()
// 数组去除指定值
let arr = [1,2,4,6,3,2,6,7,7,2,9,0,1,5]
const num = 7
arr = arr.filter(item=>item!=num)
console.log(arr);
3、给数组中的每一个对象添加属性值
forEach()
// 数组去除指定值
let arr = [{id:1,name:'sxx',},{id:2,name:'lxx',},{id:3,name:'xm',},
]
arr.forEach((item)=>{item.isPick = false;
})
console.log(arr);