当前位置:网站首页>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
}
边栏推荐
- A few lines of code to complete RPC service registration and discovery
- 【Leetcode】14. 最长公共前缀
- 智能垃圾桶(五)——点亮OLED
- Sword finger offer 24 Reverse linked list
- Sword finger offer 22 The penultimate node in the linked list
- Learning Weekly - total issue 60 - 25th week of 2022
- JS delete substring in string
- 剑指 Offer 25. 合并两个排序的链表
- Sword finger offer 21 Adjust the array order so that odd numbers precede even numbers
- Exploration of mobile application performance tools
猜你喜欢
871. Minimum refueling times
Qwebengineview crash and alternatives
一文看懂:数据指标体系的4大类型
[shutter] dart data type (dynamic data type)
使用知行之桥的API端口,提供资源供合作伙伴访问
Cell: Tsinghua Chenggong group revealed an odor of skin flora. Volatiles promote flavivirus to infect the host and attract mosquitoes
綠竹生物沖刺港股:年期內虧損超5億 泰格醫藥與北京亦莊是股東
【征文活动】亲爱的开发者,RT-Thread社区喊你投稿啦
亚马逊云科技 Community Builder 申请窗口开启
A few lines of code to complete RPC service registration and discovery
随机推荐
ThreadLocal
Blog theme "text" summer fresh Special Edition
si446使用记录(一):基本资料获取
ROS知识点——ros::NodeHandle n 和 nh(“~“)的区别
寒门再出贵子:江西穷县考出了省状元,做对了什么?
几行代码搞定RPC服务注册和发现
Role and function of uboot
【Leetcode】13. Roman numeral to integer
亚马逊云科技 Community Builder 申请窗口开启
畅玩集团冲刺港股:年营收2.89亿 刘辉有53.46%投票权
关于我
Easy language ABCD sort
QStyle实现自绘界面项目实战(二)
Changwan group rushed to Hong Kong stocks: the annual revenue was 289million, and Liu Hui had 53.46% voting rights
IDEA2021.1 安装教程
二、mock平台的扩展
Listing of chaozhuo Aviation Technology Co., Ltd.: raising 900million yuan, with a market value of more than 6billion yuan, becoming the first science and technology innovation board enterprise in Xia
2022 interview questions
Tech talk activity preview | building intelligent visual products based on Amazon kVs
Dgraph: large scale dynamic graph dataset