📌  相关文章
📜  数组 javascript 代码示例中的唯一对象

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

代码示例6
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);