当前位置:网站首页>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
}
边栏推荐
- Visibilitychange – refresh the page data when the specified tab is visible
- Believe in yourself and finish the JVM interview this time
- Configure ARP table entry restrictions and port security based on the interface (restrict users' private access to fool switches or illegal host access)
- Soul, a social meta universe platform, rushed to Hong Kong stocks: Tencent is a shareholder with an annual revenue of 1.28 billion
- 2、 Expansion of mock platform
- 详细介绍scrollIntoView()方法属性
- Usage of sprintf() function in C language
- 一文看懂:数据指标体系的4大类型
- 2020 "Lenovo Cup" National College programming online Invitational Competition and the third Shanghai University of technology programming competition (a sign in, B sign in, C sign in, D thinking +mst
- [essay solicitation activity] Dear developer, RT thread community calls you to contribute
猜你喜欢

Jiuxian's IPO was terminated: Sequoia and Dongfang Fuhai were shareholders who had planned to raise 1billion yuan

Experience home office, feel the completion of the project | community essay solicitation

智能垃圾桶(五)——点亮OLED

Sword finger offer 27 Image of binary tree

【Leetcode】13. Roman numeral to integer

使用知行之桥的API端口,提供资源供合作伙伴访问

Believe in yourself and finish the JVM interview this time

一文看懂:数据指标体系的4大类型

Soul, a social meta universe platform, rushed to Hong Kong stocks: Tencent is a shareholder with an annual revenue of 1.28 billion

QStyle实现自绘界面项目实战(二)
随机推荐
酒仙网IPO被终止:曾拟募资10亿 红杉与东方富海是股东
深度之眼(三)——矩阵的行列式
Domestic relatively good OJ platform [easy to understand]
寒门再出贵子:江西穷县考出了省状元,做对了什么?
移动应用性能工具探索之路
Does digicert SSL certificate support Chinese domain name application?
13、Darknet YOLO3
Introduce the scrollintoview() method attribute in detail
详细介绍scrollIntoView()方法属性
Eye of depth (III) -- determinant of matrix
QWebEngineView崩溃及替代方案
智能垃圾桶(五)——点亮OLED
linux安装postgresql + patroni 集群问题
Linux Installation PostgreSQL + Patroni cluster problem
Nexus簡介及小白使用IDEA打包上傳到Nexus3私服詳細教程
Ocio V2 reverse LUT
什么是敏捷开发流程
Configure ARP table entry restrictions and port security based on the interface (restrict users' private access to fool switches or illegal host access)
体验居家办公完成项目有感 | 社区征文
【征文活动】亲爱的开发者,RT-Thread社区喊你投稿啦