var arr=[1,2,4,6,3,54,3,2,1,6,9];//数组
var newArr=[];//新数组
for(var i=0;i<arr.length;i++){//循环数组
if(newArr.indexOf(arr[i])==-1){//判断新数组中是否有重复的字符
newArr.push(arr[i]) //没有重复的字符添加进新数组
}
}
document.write(newArr+'<br/>')//1,2,4,6,3,54,9
转载于:https://www.cnblogs.com/ruir/p/6609649.html