对象数组根据某个属性去重

var Arr = [{
    "name": "ZYTX",
    "age": "111111111111",
    "gender": "AAAAAA.doc"
}, {
    "name": "ZYTA",
    "age": "222222222222",
    "gender": "BBBBBB.doc"
}, {
    "name": "ZDTX",
    "age": "333333333333",
    "gender": "CCCCCC.doc"
}, {
    "name": "ZYTX",
    "age": "444444444444",
    "gender": "DDDDDD.doc"
}];
var hash = {};
Arr = Arr.reduce(function(arr, current) {
    hash[current.name] ? '' : hash[current.name] = true && arr.push(current);
    return arr
}, [])
console.log(Arr);

你可能感兴趣的:(对象数组根据某个属性去重)