如何消除一个数组里面重复的元素()

var arr1 =[1,2,2,2,3,3,3,4,5,6], arr2 = []; for(var i = 0,len = arr1.length; i< len; i++){ if(arr2.indexOf(arr1[i]) < 0){ arr2.push(arr1[i]); } } document.write(arr2); // 1,2,3,4,5,6

【如何消除一个数组里面重复的元素()】转载于:https://www.cnblogs.com/duanzhange/p/8686365.html

    推荐阅读