const removeEmpty = (arr) => arr.reduce((acc, curr) => curr ? [...acc, curr] : acc, []);
let arr = [0, 1, null, 2,undefined, '', 3]
console.log("参数为:", arr);
console.log("结果为:", removeEmpty(arr,"name"));
const removeItem = (arr, item) => arr.reduce((acc, curr) => curr === item ? acc : [...acc, curr], []);
let arr = [1, 2, 3, 4, 2, 5]
console.log("参数为:", arr);
console.log("结果为:", removeItem(arr,2));
const mapArray = (arr, fn) => arr.reduce((acc, curr) => [...acc, fn(curr)], []);
let arr = [1, 2, 3, 4, 2, 5]
console.log("参数为:", arr,(x)=>x 2);
console.log("结果为:", mapArray(arr,(x)=>x 2));
const filterArray = (arr, fn) => arr.reduce((acc, curr) => fn(curr) ? [...acc, curr] : acc, []);
let arr = [1, 2, 3, 4, 2, 5]
console.log("参数为:", arr,(x) => x % 2 === 0);
console.log("结果为:", filterArray(arr,(x) => x % 2 === 0));