//数组去重
//优化遍历数组法 function uniqueArr(array) { var r = []; for (var i = 0, l = array.length; i < l; i++) { for (var j = i + 1; j < l; j++) if (array[i].item_code === array[j].item_code) j = ++i; r.push(array[i]); } return r; }
//最简单数组去重法 function uniqueArr(array) { var n = []; for (var i = 0; i < array.length; i++) { if (n.indexOf(array[i]) == -1) n.push(array[i]); } return n; }
//排序后相邻除法 function uniqueArr(array) { array.sort(); var n = []; for (var i = 0; i < array.length; i++) { if (array[i] !== n[n.length - 1]) { n.push(array[i]); } } return n; }
//数组合并 var arr3 = arr1.concat(arr2);
标签:function,++,合并,js,length,数组,var,array From: https://www.cnblogs.com/sunline/p/18160243