方法一:
var arr=[1,3,1,4,2,2,1];
let result=Array.from(new Set(arr));
console.log(result);
方法二:
var arr=[1,3,1,4,2,2,1];
var result=[];
arr.forEach(function(item,index){
var flag=arr.indexOf(item,index+1);
if(flag===-1){
result.push(item)
}
})
console.log(result);