var arr = ['a',1,2,3,'a',4,2,3,1,4,2,8,10,null,'a'];
// 方法一
var newArr = [...new Set(arr)];
console.log(newArr);
// 方法二
var newArr = arr.reduce( (prev,cur)=>{
prev.indexOf(cur) === -1 && prev.push(cur)
return prev;
},[])
console.log(newArr)
// 方法三
function newArrMain(arr){
var newArr = [];
for(var i=0;i<arr.length;i++){
if(newArr.indexOf(arr[i]) === -1){
newArr.push(arr[i]);
}
}
console.log(newArr);
return newArr;
}
console.log(newArrMain(arr))