For complex array contains objects, create a new array using a simple indexOf new array to determine whether it contains an array element is not applicable, reduce the need to use this method:
var array = [ {"sort":"1","name":"老王"}, {"sort":"2","name":"老李"}, {"sort":"3","name":"老张"}, {"sort":"4","name":"老岳"}, {"sort":"5","name":"老刘"}, {"sort":"1","name":"老王"}, ]; unique(array); //利用reduce方法遍历数组,The first parameter is a function reduce traverse to be executed, the second parameter is the initial value of the item to true'':? obj [next.sort] = obj [Next. the Sort](item, Next) {function= ary.reduce ( ARR{};obj =varUNIQUE (ARR) { function && item.push(next); return item; },[]); return arr; }