当前位置:网站首页>js如何将带有分割符的字符串转化成一个n维数组
js如何将带有分割符的字符串转化成一个n维数组
2022-07-01 17:49:00 【马克社区】
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”]]]
更多内容请见原文,原文转载自:http://www.mark-to-win.com/tutorial/50904.html
边栏推荐
- 整形数组合并【JS】
- (12) About time-consuming printing
- Is it reasonable and safe to open a securities account for 10000 shares free of charge? How to say
- 线上开通ETF基金账户安全吗?有哪些步骤?
- Leetcode records - sort -215, 347, 451, 75
- (十六)ADC转换实验
- 官宣!香港科技大学(广州)获批!
- 网上股票开户安全吗?是否可靠?
- The reviewboard has 500 errors when submitting a review. Solutions
- Countdownlatch blocking wait for multithreading concurrency
猜你喜欢

(27) Open operation, close operation, morphological gradient, top hat, black hat

Penetration practice vulnhub range Keyring

(17) DAC conversion experiment

多线程使用不当导致的 OOM

为什么你要考虑使用Prisma

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

Wechat applet blind box - docking wechat payment

Length of learning and changing

How to write good code - Defensive Programming Guide
![[splishsplash] about how to receive / display user parameters, MVC mode and genparam on GUI and JSON](/img/83/9bd9ce7608ebfe7207ac008b9e8ab1.png)
[splishsplash] about how to receive / display user parameters, MVC mode and genparam on GUI and JSON
随机推荐
Cookies and session keeping technology
Equipment simulation and deduction training system software
Why should you consider using prism
多线程使用不当导致的 OOM
Report on research and investment prospects of UHMWPE industry in China (2022 Edition)
The reviewboard has 500 errors when submitting a review. Solutions
[wrung Ba wrung Ba is 20] [essay] why should I learn this in college?
Openlayers customize bubble boxes and navigate to bubble boxes
Yyds dry inventory MySQL RC transaction isolation level implementation
Is the software of futures pioneer formal and safe? Which futures company is safer to choose?
中国锦纶长丝缝纫线发展预测与投资方向研究报告(2022版)
Key points on February 15, 2022
Smart factory digital management system software platform
Iommu/smmuv3 code analysis (10) page table operation
官宣!香港科技大学(广州)获批!
DNS
Petrv2: a unified framework for 3D perception of multi camera images
C language implementation of sum of two numbers [easy to understand]
Heavy disclosure! Hundreds of important information systems have been invaded, and the host has become a key attack target
The new server is packaged with the source code of H5 mall with an operation level value of several thousand