第一种
var arr4 = ["a","b","a","c","a"];
var obj = {};
var tmp = [];
for (var i = 0;i<arr4.length;i++){
if(!obj[arr4[i]]){
obj[arr4[i]] = 1;
tmp.push(arr4[i]);
}
}
console.log(tmp);
第二种
var arr5=[];
for (var i=0;i<arr4.length;i++){
if(arr5.indexOf(arr4[i])<0){
arr5.push(arr4[i]);
}
}
console.log(arr5);
第三种
var arr6 = arr4.filter(function(elements,index,self){
return self.indexOf(elements) === index;
});
console.log(arr6);