当前位置:网站首页>JS how to convert a string with a delimiter into an n-dimensional array
JS how to convert a string with a delimiter into an n-dimensional array
2022-07-01 17:54:00 【Mark community】
var str = “A-2-12”; var str1 = str.split(’-’); console.log(str1); var arr = str1.reverse().reduce((pre,cur,i) => { if(i==0) { pre.push(cur) return pre } return [cur,pre] },[]) console.log(arr) // [“A”[“B”,[“C”]]]
For more information, please refer to the original , Reproduced from :http://www.mark-to-win.com/tutorial/50904.html
边栏推荐
- Alibaba cloud Li Feifei: China's cloud database has taken the lead in many mainstream technological innovations abroad
- Penetration practice vulnhub range Nemesis
- Pyqt5, draw a histogram on the control
- 手机开户股票开户安全吗?那么开户需要带些什么?
- Replace UUID, nanoid is faster and safer!
- February 16, 2022 Daily: graph neural network self training method under distribution and migration
- New patent applications and transfers
- 官宣!香港科技大学(广州)获批!
- 两数之和c语言实现[通俗易懂]
- Roewe rx5's "a little more" product strategy
猜你喜欢
An example of data analysis of an old swatch and an old hard disk disassembly and assembly combined with the sensor of an electromagnetic press
People help ant help task platform repair source code
LeetCode中等题之TinyURL 的加密与解密
官宣!香港科技大学(广州)获批!
Gameframework eating guide
Penetration practice vulnhub range Tornado
整形数组合并【JS】
(十六)ADC转换实验
Detailed explanation of string's trim() and substring()
Quick foundation of group theory (5): generators, Kelley graphs, orbits, cyclic graphs, and "dimensions" of groups?
随机推荐
Technical secrets of ByteDance data platform: implementation and optimization of complex query based on Clickhouse
Encryption and decryption of tinyurl in leetcode
(17) DAC conversion experiment
D @ safety and dip1000
官宣!香港科技大学(广州)获批!
Maizeer: the two batches of products reported by the media have been taken off the shelves and sealed, and consumer appeals are accepted
The latest intelligent factory MES management system software solution
Enter wechat applet
提交review时ReviewBoard出现500错误解决方法
Redis主从实现10秒检查与恢复
开发那些事儿:EasyCVR集群设备管理页面功能展示优化
Zabbix报警执行远程命令
Equipment simulation and deduction training system software
网上股票开户安全吗?是否可靠?
Gold, silver and four job hopping, interview questions are prepared, and Ali becomes the champion
Reflective XSS vulnerability
中国超高分子量聚乙烯产业调研与投资前景报告(2022版)
New patent applications and transfers
Official announcement! Hong Kong University of science and Technology (Guangzhou) approved!
Sword finger offer II 105 Maximum area of the island