对象去重

对象去重 -----------------------------------------------------

var arr = [{reportRole: "检验员"},{reportRole: "检验员"},{reportRole: "检验员"}]
var hash = {};
arr = arr.reduce((preVal, curVal) => {
hash[curVal.reportRole] ? '' : hash[curVal.reportRole] = true && preVal.push(curVal);
return preVal
}, []);

 

posted @ 2020-04-23 13:46  queenDream  阅读(599)  评论(0编辑  收藏  举报