当前位置:网站首页>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
边栏推荐
- [wrung Ba wrung Ba is 20] [essay] why should I learn this in college?
- February 16, 2022 Daily: graph neural network self training method under distribution and migration
- DRF --- response rewrite
- Research Report on development prediction and investment direction of nylon filament sewing thread in China (2022 Edition)
- Encryption and decryption of tinyurl in leetcode
- Sword finger offer II 105 Maximum area of the island
- There is a new breakthrough in quantum field: the duration of quantum state can exceed 5 seconds
- Penetration practice vulnhub range Nemesis
- MySQL -- explain performance optimization
- Data warehouse (3) star model and dimension modeling of data warehouse modeling
猜你喜欢

vulnhub靶场-hacksudo - Thor

Encryption and decryption of tinyurl in leetcode

Vulnhub range hacksudo Thor

Cookies and session keeping technology

(28) Shape matching based on contour features

DNS

Gold, silver and four job hopping, interview questions are prepared, and Ali becomes the champion

剑指 Offer 20. 表示数值的字符串

June issue | antdb database participated in the preparation of the "Database Development Research Report" and appeared on the list of information technology and entrepreneurship industries

(十七)DAC转换实验
随机推荐
Thinkphp6 - CMS multi wechat management system source code
中国PBAT树脂市场预测及战略研究报告(2022版)
ACL 2022 | decomposed meta learning small sample named entity recognition
Shenyu gateway development: enable and run locally
China biodegradable plastics market forecast and investment strategy report (2022 Edition)
官宣!香港科技大学(广州)获批!
[mathematical modeling] [matlab] implementation of two-dimensional rectangular packing code
剑指 Offer 20. 表示数值的字符串
String的trim()和substring()详解
JDBC: deep understanding of Preparedstatement and statement[easy to understand]
[Verilog quick start of Niuke network question brushing series] ~ priority encoder circuit ①
Report on research and investment prospects of UHMWPE industry in China (2022 Edition)
Official announcement! Hong Kong University of science and Technology (Guangzhou) approved!
Mysql database - Advanced SQL statement (2)
(28) Shape matching based on contour features
为什么你要考虑使用Prisma
C language implementation of sum of two numbers [easy to understand]
【Try to Hack】vulnhub DC4
ACM mm 2022 video understanding challenge video classification track champion autox team technology sharing
中国乙腈市场预测与战略咨询研究报告(2022版)