📌  相关文章
📜  在javascript 5中的对象数组中查找唯一对象 - Javascript代码示例

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

代码示例3
var array = [{"name":"Joe", "age":17}, {"name":"Bob", "age":17}, {"name":"Carl", "age": 35}];
var unique = [];
var distinct = [];
for(var i = 0; i < array.length; i++ ){
  if(!unique[array[i].age]){
    distinct.push(array[i]);
    unique[array[i].age] = 1;
  }
}


gs.info(distinct);