SOURCE

const names = ['Alice', 'Bob', 'Tiff', 'Bruce', 'Alice', 'Bob', 'Bob'];
names.reduce((pre,cur,index)=>{
    // console.log(pre,cur,index)
    // console.log(cur in pre)
    if(cur in pre){

       pre[cur]++
    }else{
         pre[cur]=1;
    }
    return pre;
},{})
// console.log(names)


  const arr = [1, 2, 3, 4, 4, 1]
    let newArr = arr.reduce((pre, cur) => {
        console.log(pre,cur)
        if (!pre.includes(cur)) {
            return pre.concat(cur)
        } else {
            return pre
        }
    }, [])
console.log(newArr);// [1, 2, 3, 4]
console 命令行工具 X clear

                    
>
console