var arr = [1,2,3,1,1,1,3,5,3,6,2]; var newArr=[]; for(var i = 0; i < arr.length-1; i++){ var onOff = false; for(var j = i-1;j >= 0;j--){ if(arr[i]==arr[j]) { onOff = true; break; } } if(!onOff) newArr[newArr.length]=arr[i] } alert(newArr)
时间: 2024-10-14 23:45:41