JavaScript 数组中对象去重方法:
var array = [{id=1},{id=3},{id=3},{id=5},{id=5},{id=7},{id=9}]; var hash = {}; array = array.reduce(function (item, next) { hash[next.id] ? '' : hash[next.id] = true && item.push(next); return item; }, []);
JavaScript 数组中对象去重方法:
var array = [{id=1},{id=3},{id=3},{id=5},{id=5},{id=7},{id=9}]; var hash = {}; array = array.reduce(function (item, next) { hash[next.id] ? '' : hash[next.id] = true && item.push(next); return item; }, []);