SOURCE

// --------------第一种方法------------
function fn1() {
    const a = [2, 2, 2, 3, 3, 3, 4, 4, 5, 5];
    console.log([...new Set(a)])
}
// fn1()


// ---------------第二种方法------------------
function fn2() {
    const b = [2, 2, 2, 3, 3, 3, 4, 4, 5, 5];
    console.log(Array.from(new Set(b)));
}
// fn2()


// ----------------第三种方法-------------------
function fn3(test){
    const arr = [];
    for(let i = 0;i<array.length;i++){
        if(arr.indexOf(array[i])==-1){
            arr.push(array[i])
        }
    }
    return arr
}
const array = [2,2,'a','a',4,4,5,6,7,'w','w'];
// console.log(fn3(array))


// -----------------第四种方法---------------
function fn4(test2){
    const arr2=[];
    for(let i=0;i<array2.length;i++){
        if(!arr2.includes(array2[i])){
            arr2.push(array2[i])
        }
    }
    return arr2;
}
const array2 = [2,2,'a','a',4,4,5,6,7,'w','w'];
// console.log(fn4(array))


//----------------第五种方法------------------
function fn5(test3){
    return arr3.filter(function(item,index,arr3){
        return arr3.indexOf(item,0)==index;
    });
}
const arr3 = [2,2,'a','a',4,4,5,6,7,'w','w'];
console.log(fn5(arr3))
console 命令行工具 X clear

                    
>
console