var arr2=[1,5,1,12,41,8,5,14,21,2,12,41,32,8];function myfilter(item,index){return arr2.indexOf(item)== index;}
console.log('arr2',arr2.filter(myfilter))
方法三: 判断当前元素第一次出现的位置是否与其在数组中的索引相同
var arr3=[1,5,1,12,41,8,5,14,21,2,12,41,32,8];
var newarr3=[];
for(var i=0;i<arr3.length;i++){
if(arr3.indexOf(arr3[i])== i){
newarr3.push(arr3[i]);}}
console.log('newarr3',newarr3)