對象數組根據某個屬性去重

let data = [ {id:1,name:'obj'}, {id:3,name:'string'}, {id:2,name:'arr'}, {id:1,name:'num'} ]; let hash = {}; data = data.reduce(function(arr, current) { hash[current.id] ? '' : has
相關文章
相關標籤/搜索