去除数组中重复元素
var arr=["a","b","c","a","a","b","d"]; function fn(array){ var newArr=[]; for(var i=0;i<array.length;i++){ var bool=true; for(var j=0;j<newArr.length;j++){ if(array[i]===newArr[j]){ bool=false; } } if(bool){ newArr[newArr.length]=array[i]; } } return newArr; } console.log(fn(arr)); // ["a", "b", "c", "d"]