js中如何实现数组去重--面试题
1 function dupRemove(arr){ 2 var tmp = []; 3 for(var i=0;i<arr.length;i++){ 4 for(var j=i+1;j<arr.length;j++){ 5 if(arr[i] === arr[j]){ 6 j = ++i; 7 } 8 } 9 tmp.push(arr[i]); 10 } 11 return tmp; 12 } 13 14 var list = [10,20,50,60,10,20,'a','v','a']; 15 document.write(dupRemove(list)); //50,60,10,20,v,a