JS 数组去重复值
var arr1 = [90, 91, 92];
var arr2 = [80, 81];
var arr3 = [80, 71, 72, 73];
var arr = arr1.concat(50, 60, arr2, arr3);
//console.log(arr1); //现有数组值不变
//console.log(arr);
var result = unique(arr);// 去除数组中的重复值
console.log(result);
function unique(arr) {
debugger;
var result = [], hash = {};
for (var i = 0, elem; (elem = arr[i]) != null; i++) {
if (!hash[elem]) {
result.push(elem);
hash[elem] = true;
}
}
return result;
}