Set()对象里的值具有唯一性,我们可以利用这个特性进行数组去重
let arr=[2,2,2,8,8,55,55,0.1,0.1,"i","i",null,null,undefined,undefined,NaN,NaN];
let newArr=[];
function removing(arr){
newArr=Array.from(new Set(arr));//Array.from浅拷贝
}
removing(arr);
console.log(newArr);//[2, 8, 55, 0.1, "i", null, undefined, NaN]