JS对以对象组成的数组去重

这是从https://segmentfault.com/q/1010000006954351参考的,达到了我要去重的功能!!!
var hash = {};
//arr是要去重的对象数组 arr = arr.reduce(function(item, next) { hash[next.name] ? '' : hash[next.name] = true && item.push(next); return item }, []) console.log(arr);

  



posted @ 2018-05-09 11:51  小伍w  阅读(1374)  评论(0编辑  收藏  举报