const flatten = (arr, depth = 1) =>
depth != 1
? arr.reduce((a, v) => a.concat(Array.isArray(v) ? flatten(v, depth - 1) : v), [])
: arr.reduce((a, v) => a.concat(v), [])
标签:isArray,平铺,arr,reduce,depth,flatten,数组,深度,concat
来源: https://www.cnblogs.com/wuqilang/p/15103890.html