数组去重
程序员文章站
2022-05-13 09:16:58
...
var arr = ['0','1','2','3','0']; function rep(arr){ var new_arr = [arr[0]]; for (var i = 0; i < arr.length; i++) { if(new_arr.indexOf(arr[i]) == -1 ){ new_arr.push(arr[i]); } } return new_arr; } rep(arr); //["0", "1", "2", "3"]