js筛选数组排除多个多个不符合项

const arr = [
  {
    label: '2',
    value: '2'
  },
  {
    label: '1',
    value: '1'
  },
  {
    label: '3',
    value: '3'
  }
]
// 把value=1和value=2的数据筛掉
let newArr = arr.filter(opt => 
  ['1', '2'].includes(opt.value)
)
console.log(newArr) // [{label: '3', value: '3'}]

 

posted @ 2023-08-18 13:32  芒果不忙-  阅读(182)  评论(0)    收藏  举报