当前位置:网站首页>JS20 数组扁平化
JS20 数组扁平化
2022-07-02 14:51:00 【淹死的鱼u】
题解:递归数组判断
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
}
边栏推荐
猜你喜欢

Weili holdings listed on the Hong Kong Stock Exchange: with a market value of HK $500million, it contributed an IPO to Hubei

GeoServer:发布PostGIS数据源

伟立控股港交所上市:市值5亿港元 为湖北贡献一个IPO

Sword finger offer 25 Merge two sorted linked lists

移动应用性能工具探索之路

Eth data set download and related problems

七张图,学会做有价值的经营分析

Connect Porsche and 3PL EDI cases

相信自己,这次一把搞定JVM面试

福元医药上交所上市:市值105亿 胡柏藩身价超40亿
随机推荐
LeetCode:1380. Lucky number in matrix -- simple
ThreadLocal
绿竹生物冲刺港股:年期内亏损超5亿 泰格医药与北京亦庄是股东
Ocio V2 reverse LUT
Schoolbag novel multithreaded crawler [easy to understand]
Linux Installation PostgreSQL + Patroni cluster problem
Introduction to Hisilicon hi3798mv100 set top box chip [easy to understand]
Shutter: action feedback
移动应用性能工具探索之路
关于我
Chmod command principle and usage details [easy to understand]
Leetcode question brushing record | 933_ Recent requests
Sword finger offer 21 Adjust the array order so that odd numbers precede even numbers
一年頂十年
&lt; IV & gt; H264 decode output YUV file
chmod命令原理及用法详解[通俗易懂]
Configure MySQL under Linux to authorize a user to access remotely, which is not restricted by IP
[leetcode] 14. Préfixe public le plus long
对接保时捷及3PL EDI案例
剑指 Offer 22. 链表中倒数第k个节点