var str1=["a","b","c","a","a","g","r"];
var obj={};
var str2=[];
for(var i=0;i
if(!obj[str1[i]]){
obj[str1[i]]=1;
str2.push(str1[i]);
}
}
console.log(str2);
//filter方法
var arr = [2,3,4,4,5,2,3,6];
var arr2 = arr.filter(function(element,index,self){
// console.log(element);
// console.log(index);
// console.log(self);
return self.indexOf(element) === index;
});
// console.log(arr2);
网友评论