标签:amr for 实现 push log OLE const prot type
function steamrollArray(arr) {
let res = []
for (const a of arr) {
if(a instanceof Array){
res = res.concat(steamrollArray(a))
}else{
res.push(a)
}
}
return res;
}
console.log(steamrollArray([1, [2], [3, [[4]]]]));// [1,2,3,4]
console.log([1, [2], [3, [[4]]]].flat(Infinity)); // [1,2,3,4]
标签:amr for 实现 push log OLE const prot type
原文地址:https://www.cnblogs.com/roseAT/p/12305937.html