当前位置:网站首页>JS20 array flattening
JS20 array flattening
2022-07-02 17:23:00 【Drowned fish u】
Answer key : Recursive array judgment
let newarr = []
const _flatten = arr => {
// The completion code
let i = 0;
while(i < arr.length) {
if (Array.isArray(arr[i])) {
_flatten(arr[i])
} else {
newarr.push(arr[i])
}
i++
}
return newarr
}
边栏推荐
- Does digicert SSL certificate support Chinese domain name application?
- 剑指 Offer 21. 调整数组顺序使奇数位于偶数前面
- 2022 interview questions
- Timing / counter of 32 and 51 single chip microcomputer
- ceph 原理
- TCP congestion control details | 2 background
- 【Leetcode】14. 最长公共前缀
- Vscode setting delete line shortcut [easy to understand]
- Nexus Introduction and Xiaobai use idea Packaging and Upload to Nexus 3 private service detailed tutoriel
- [shutter] dart data type (dynamic data type)
猜你喜欢
随机推荐
IP address translation address segment
Jiuxian's IPO was terminated: Sequoia and Dongfang Fuhai were shareholders who had planned to raise 1billion yuan
Visibilitychange – refresh the page data when the specified tab is visible
Domestic relatively good OJ platform [easy to understand]
Eye of depth (III) -- determinant of matrix
VScode知识点——常见报错
ThreadLocal
A few lines of code to complete RPC service registration and discovery
Tech talk activity preview | building intelligent visual products based on Amazon kVs
Geoserver: publishing PostGIS data sources
Dgraph: large scale dynamic graph dataset
Idea2021.1 installation tutorial
QWebEngineView崩溃及替代方案
伟立控股港交所上市:市值5亿港元 为湖北贡献一个IPO
Method of C language self defining function
Amazon cloud technology community builder application window opens
Sword finger offer 22 The penultimate node in the linked list
剑指 Offer 24. 反转链表
剑指 Offer 21. 调整数组顺序使奇数位于偶数前面
从收集到输出:盘点那些强大的知识管理工具——优秀笔记软件盘点(四)