当前位置:网站首页>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
边栏推荐
- DRF --- response rewrite
- PHP实现敏感词过滤系统「建议收藏」
- Depth first traversal and breadth first traversal [easy to understand]
- Encryption and decryption of tinyurl in leetcode
- Alibaba cloud Li Feifei: China's cloud database has taken the lead in many mainstream technological innovations abroad
- Thinkphp6 - CMS multi wechat management system source code
- Intel's open source deep learning tool library openvino will increase cooperation with local software and hardware parties and continue to open
- Penetration practice vulnhub range Tornado
- ArrayList扩容详解
- 整形数组合并【JS】
猜你喜欢

Setting up a time server requires the client to automatically synchronize the time of the server at 9 a.m. every day

Official announcement! Hong Kong University of science and Technology (Guangzhou) approved!

官宣!香港科技大学(广州)获批!

Heavy disclosure! Hundreds of important information systems have been invaded, and the host has become a key attack target

(16) ADC conversion experiment
![[PHP foundation] realize the connection between PHP and SQL database](/img/eb/c8953eddfe3b19b0adb5529957d275.jpg)
[PHP foundation] realize the connection between PHP and SQL database

PETRv2:一个多摄像头图像3D感知的统一框架

People help ant help task platform repair source code

Kernel stray cat stray dog pet adoption platform H5 source code
![Htt [ripro network disk link detection plug-in] currently supports four common network disks](/img/e4/c06b94243cdbe391b8b2124ff30789.jpg)
Htt [ripro network disk link detection plug-in] currently supports four common network disks
随机推荐
MySQL -- explain performance optimization
How to write good code - Defensive Programming Guide
Sword finger offer 20 String representing numeric value
(1) CNN network structure
ACL 2022 | decomposed meta learning small sample named entity recognition
Oom caused by improper use of multithreading
The reviewboard has 500 errors when submitting a review. Solutions
整形数组合并【JS】
The latest intelligent factory MES management system software solution
China biodegradable plastics market forecast and investment strategy report (2022 Edition)
Kernel stray cat stray dog pet adoption platform H5 source code
Source code of new campus errand / campus task platform on mutual station
golang中的select详解
Euler function: find the number of numbers less than or equal to N and coprime with n
[Verilog quick start of Niuke network question brushing series] ~ priority encoder circuit ①
String的trim()和substring()详解
China metallocene polyethylene (MPE) Industry Research Report (2022 Edition)
(17) DAC conversion experiment
Three dimensional anti-terrorism Simulation Drill deduction training system software
Htt [ripro network disk link detection plug-in] currently supports four common network disks