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);

  



原文地址:https://www.cnblogs.com/wgl0126/p/9013356.html