题解 | #数组扁平化#
数组扁平化
https://www.nowcoder.com/practice/5d7e0cf4634344c98e6ae4eaa2336bed
题解:递归数组判断
let newarr = [] const _flatten = arr => { // 补全代码 let i = 0; while(i < arr.length) { if (Array.isArray(arr[i])) { _flatten(arr[i]) } else { newarr.push(arr[i]) } i++ } return newarr }