js根据对象的属性值进行数组去重

//第一种
            var hash = {};
            var Arr = newArr.reduce(function(arr, current) {
                hash[current.singerid] ? '' : hash[current.singerid] = true && arr.push(current);
                return arr
            }, [])
            //第二种
            const maps = new Map();
            console.log(newArr.filter((a) => !maps.has(a.singerid) && maps.set(a.singerid, 1)));

 

posted @ 2020-03-13 14:21  南瓜壳  阅读(1379)  评论(0编辑  收藏  举报