let arr = [1,2,[false,“adsaf”,12],[[3],[{x:100}]]];
console.log(arr.toString());
function reduction(arr, target = []){
arr.forEach(function(e){
if(e instanceof Array){
reduction(e, target);
}else{
target.push(e);
}
})
return target;
}
console.log(reduction(arr));
数组降维——任意类型
最新推荐文章于 2021-12-08 19:47:03 发布