记录:(简单记录)js数组对象去重

it2022-05-05  175

对数组内多个对象的去重

let Result = [] // 去重后的item的容器 let Obj = {} // 条件容器 for(let i = 0; i < array.length; i ++){ if(!Obj[array[i].key]){ Result.push(array[i]) Obj[array[i].key] = true } } console.log(Result) // 结果

注意:简单记录,没有罗列其它简单去重、深度去重的方法


最新回复(0)