SOURCE

function Fill(arr = [], val = '', start = 0, end = arr.length){
    if(start < 0 || start >= end || end > arr.length) return arr;
    return [
        ...arr.slice(0, start),
        ...arr.slice(start, end).reduce((t, v) => (t.push(val || v), t),[]),
        ...arr.slice(end, arr.length)
    ];
}
const arr = [0,1,2,3,4,5,6];
console.log(Fill(arr, 'aaa', 2, 5));


function Flat(arr1 = []){
    return arr1.reduce((t,v) => t.concat(Array.isArray(v) ? Flat(v) : v),[]);
}
console.log(Flat([1,3,[1,2,[3]]]))


function Uniq(arr = []){
    return arr.reduce((t, v) => t.includes(v) ? t : [...t, v], []);
}
console.log(Uniq([1,2,0,3,2,1,2]))

console 命令行工具 X clear

                    
>
console