数组对象(json)去重

/**
array要去重的数组
key数组中的的唯一标识符

**/
uniqueArray(array, key){
let result = [array[0]];
for(let i = 1; i < array.length; i++){
let item = array[i];
let repeat = false;
for (let j = 0; j < result.length; j++) {
if (item[key] == result[j][key]) {
repeat = true;
break;
}
}
if (!repeat) {
result.push(item);
}
}
return result;
},
原文地址:https://www.cnblogs.com/boonook/p/9935039.html