SOURCE

arr = [1,3,4,5];

const a = arr.map(v=> v*2);
const b = arr.reduce((t,v) => [...t, v*2],[]);
console.log(b);

const c = arr.filter(v => v > 1);
const d = arr.reduce((t, v) => v > 1 ? [...t, v] : t, []);
console.log('filter', c);
console.log('reduce', d);

const e = arr.map(v => v *2).filter(v => v > 2);
const f = arr.reduce((t, v) => v*2 > 2 ? [...t, v*2] : t, []);
console.log('map + filter', e);
console.log('reduce', f);


console 命令行工具 X clear

                    
>
console