当前位置:网站首页>(JS) array flat
(JS) array flat
2022-06-29 11:12:00 【Yu Cainiao, who asked not to be named】
- If there is only one layer of nested arrays
Array.prototype.concat.apply([], arr)
or
[].concat(arr)
or
Array.prototype.concat.call([], arr[0],arr[1]...)
- If there are multiple nesting
function flat(arr) {
// Determine whether there is a multi-layer array
const isDeep = arr.some(item => {
return item instanceof Array;
});
// If there is no multi-level array , Then return to arr
if (!isDeep) {
return arr;
}
const res = Array.prototype.concat.apply([], arr);
return flat(res)
}
边栏推荐
- Getting started with the lvgl Library - Animation
- 【各种**问题系列】OLTP和OLAP是啥?
- Easydss is deployed on Disk C, and the video playback cannot be played normally. How to solve this problem?
- (JS) status mode
- Shell 引号和转义从来很少被人注意,但平时写脚本又经常用
- 任职 22 年,PowerShell 之父将从微软离职:曾因开发 PowerShell 被微软降级过
- NUC980开源项目16-从SPI FLASH(W25Q128)启动
- crypto 1~5
- 企业竞争分析的几种方法:SWOT、波特五力、PEST「建议收藏」
- what? It's amazing that you can read the whole comic book for free. You can't learn to be a money saver together
猜你喜欢

非凸联合创始人李佐凡:将量化作为自己的终身事业

Modbustcp protocol WiFi wireless learning single channel infrared module (small shell version)

ModbusTCP协议WIFI无线学习型单路红外模块(小壳版)

任职 22 年,PowerShell 之父将从微软离职:曾因开发 PowerShell 被微软降级过

EasyDSS部署在C盘,录像回看无法正常播放该如何解决?
![[FreeRTOS] 08 mutex semaphores and priority inversion](/img/16/9715d5599db6ec107c8001fbd70ae2.png)
[FreeRTOS] 08 mutex semaphores and priority inversion

Interview questions of Tencent automation software test of CSDN salary increase secret script (including answers)
![[digital signal modulation] realize signal modulation and demodulation based on am+fm+dsb+ssb, including Matlab source code](/img/76/bcf0118c8eea2b45b47eda4a68d3fd.png)
[digital signal modulation] realize signal modulation and demodulation based on am+fm+dsb+ssb, including Matlab source code

在Clion中使用EasyX配置

csdn涨薪秘籍之腾讯自动化软件测试面试题(含答案)
随机推荐
如何通过WinDbg获取方法参数值
Pipeline aggregations管道聚合- parent-2
ModbusTCP协议WIFI无线学习型单路红外模块(小壳版)
NUC980开源项目16-从SPI FLASH(W25Q128)启动
《Datawhale推荐系统教程》来了!
Modbustcp protocol network learning single channel infrared module (medium shell version)
(JS)职责链模式
(JS)数组去除重复
Modbustcp protocol WiFi wireless learning single channel infrared module (small shell version)
Nuc980 open source project 16- start from SPI flash (w25q128)
When the "Ai x scientific computing" is in progress, Huawei's mindspore competition question is hot, waiting for you!
(JS)观察者模式
Data analysis method and Thinking: funnel analysis
map合并相同的键,值合并为列表
Free books! The best-selling book "Introduction and practice of OpenCV image processing" has been completed
misc3~7
Uboot for embedded driver development -- common command parameters in uboot
np. astype()
misc3~7
STM32F1与STM32CubeIDE编程实例-超声波测距传感器驱动