📜  基于proeperty js的数组减少和计数 - Javascript代码示例

📅  最后修改于: 2022-03-11 15:03:57.293000             🧑  作者: Mango

代码示例1
const array = [
  {id: 12, name: 'toto'},
  {id: 12, name: 'toto'},
  {id: 42, name: 'tutu'},
  {id: 12, name: 'toto'},
];

const id = 12;
const count = array.filter((obj) => obj.id === id).length;

console.log(count);