1,对数组的过滤
let arr = ['1', '2', '3'] let b = arr.filter(val => val === '2') console.log(b) // ['2]
2,对象的过滤
let objArr = [ {id: 1, label: '影视'}, {id: 2, label: '动漫'}, {id: 3, label: '音乐'} ] let c = objArr.filter(val => { return val.label === '音乐' }) console.log(c) // {id: 3, label: "音乐"}