ES6 数组去重
/** * 数组去重 */ global.unique = function(arr, ... keys){ if(keys.length == 0){ keys = ['id']; } let exists = new Set(); let result = arr.reduce(function(dist, item){ let karr = []; keys.forEach(k =>{ karr.push(item[k]); }); let kstr = karr.join("#\n#"); if(!exists.has(kstr)){ dist.push(item); exists.add(kstr); } return dist; }, []) return result; }