当前位置:网站首页>JS converts tree structure data into one-dimensional array data
JS converts tree structure data into one-dimensional array data
2022-04-23 08:15:00 【suoh's Blog】
// Convert tree data to one-dimensional array
getOneArr(arr) {
let data = JSON.parse(JSON.stringify(arr))
let newData = []
const callback = (item) => {
(item.children || (item.children = [])).map(v => {
callback(v)
})
delete item.children
newData.push(item)
}
data.map(v => callback(v))
return newData
},
版权声明
本文为[suoh's Blog]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230700098642.html
边栏推荐
- [go] common concurrency model [generic version]
- LeetCode中等题之旋转函数
- LeetCoed18. 四数之和
- 2022.4.11-4.17 AI行业周刊(第93期):AI行业的困局
- Ubuntu安装Mysql并查询平均成绩
- [problem solving] vs2019 solves the problem that the EXE file generated by compilation cannot be opened
- 万物互联下如何对设备进行加密
- 求3个字符串(每串不超过20个字符)中的最大者。
- 编译原理题-带答案
- Kubernetes in browser and IDE | interactive learning platform killercoda
猜你喜欢
搜一下导航完整程序源码
thinkphp6+jwt 实现登录验证
WordPress爱导航主题 1.1.3 简约大气网站导航源码网址导航源码
每周leetcode - 06 数组专题 7~739~50~offer 62~26~189~9
Anti shake and throttling
[programming practice / embedded competition] learning record of embedded competition (I): establishment of TCP server and web interface
分布式服务治理Nacos
NLLLoss+log_SoftMax=CE_Loss
岛屿的个数
An article understands variable lifting
随机推荐
PHP generates short links: convert numbers to letters and letters to numbers
Distributed service governance Nacos
Ribbon start process
[programming practice / embedded competition] learning record of embedded competition (I): establishment of TCP server and web interface
Vowel substring in statistical string of leetcode simple problem
【解释】get ORA-12838: cannot read/modify an object after modifying it in parallel
Thinkphp6 + JWT realizes login verification
社区团购小程序源码+界面diy+附近团长+供应商+拼团+菜谱+秒杀+预售+配送+直播
Convert object to URL
[go] common concurrency model [generic version]
几种智能机器人室内定位方法对比
LeetCode15. 三数之和
[Effective Go 中文翻译]函数篇
将实例化对象的方法 给新的对象用
Find the largest of 3 strings (no more than 20 characters per string).
Briefly describe the hierarchical strategy of memory
AAAI 2022招募讲者啦!!
Compiling principle questions - with answers
Quick rehearsal exercise
输入 “ net start mysql ”,出现 “ 发生系统错误 5。 拒绝访问 ” 。问题详解