当前位置:网站首页>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
}
边栏推荐
- Exploration of mobile application performance tools
- Linux Installation PostgreSQL + Patroni cluster problem
- helm kubernetes包管理工具
- IDEA2021.1 安装教程
- 剑指 Offer 21. 调整数组顺序使奇数位于偶数前面
- 远程办公对我们的各方面影响心得 | 社区征文
- Usage of sprintf() function in C language
- Sword finger offer 27 Image of binary tree
- Sword finger offer 26 Substructure of tree
- PCL知识点——体素化网格方法对点云进行下采样
猜你喜欢

Tech talk activity preview | building intelligent visual products based on Amazon kVs

linux安装postgresql + patroni 集群问题

Blog theme "text" summer fresh Special Edition

Baobab's gem IPO was terminated: Tang Guangyu once planned to raise 1.8 billion to control 47% of the equity

剑指 Offer 21. 调整数组顺序使奇数位于偶数前面

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

宝宝巴士创业板IPO被终止:曾拟募资18亿 唐光宇控制47%股权

体验居家办公完成项目有感 | 社区征文

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

【Leetcode】14. 最长公共前缀
随机推荐
一文看懂:数据指标体系的4大类型
si446使用记录(二):使用WDS3生成头文件
si446使用记录(一):基本资料获取
QWebEngineView崩溃及替代方案
LSF basic command
简单介绍BASE64Encoder的使用
体验居家办公完成项目有感 | 社区征文
Qstype implementation of self drawing interface project practice (II)
visibilitychange – 指定标签页可见时,刷新页面数据
Sword finger offer 26 Substructure of tree
PCL知识点——体素化网格方法对点云进行下采样
Nexus簡介及小白使用IDEA打包上傳到Nexus3私服詳細教程
2、 Expansion of mock platform
几行代码搞定RPC服务注册和发现
Exploration of mobile application performance tools
云通信接口更新迭代——SUBMAIL API V4正式上线
酒仙网IPO被终止:曾拟募资10亿 红杉与东方富海是股东
简单线性规划问题
IDEA2021.1 安装教程
深度之眼(三)——矩阵的行列式