js实现数组降维算法[不准用Array.prototype.flat的api]
// target要降维的元素,n降维阶数,newArr存储结果的新数组
function f(target, n = 1, newArr = []) {if (n < 0) {newArr.push(target);return;}if (!Array.isArray(target)) {newArr.push(target);} else {target.forEach(e => {f(e, n - 1, newArr);});}return newArr;
}