当前位置:网站首页>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
边栏推荐
- About selenium element positioning being overwritten
- 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
- 提交review时ReviewBoard出现500错误解决方法
- String的trim()和substring()详解
- Vulnhub range hacksudo Thor
- Is the software of futures pioneer formal and safe? Which futures company is safer to choose?
- PIP version problems: PIP problems still occur when installing akshare and using Tsinghua source and Douban source
- China acetonitrile market forecast and strategic consulting research report (2022 Edition)
- Object. fromEntries()
- Blackwich: the roadmap of decarbonization is the first step to realize the equitable energy transformation in Asia
猜你喜欢

Kia recalls some K3 new energy with potential safety hazards

整形数组合并【JS】

Yyds dry inventory MySQL RC transaction isolation level implementation

Common design parameters of solid rocket motor

Why should you consider using prism

Penetration practice vulnhub range Nemesis

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

ISO 27001 Information Security Management System Certification

(17) DAC conversion experiment

Rotation order and universal lock of unity panel
随机推荐
【Try to Hack】vulnhub DC4
2022 Heilongjiang latest fire protection facility operator simulation test question bank and answers
C language implementation of sum of two numbers [easy to understand]
Development cost of smart factory management system software platform
Rotation order and universal lock of unity panel
Sword finger offer 20 String representing numeric value
Oom caused by improper use of multithreading
Good looking UI mall source code has been scanned, no back door, no encryption
中国茂金属聚乙烯(mPE)行业研究报告(2022版)
Source code of new campus errand / campus task platform on mutual station
Fresh, 2022 advanced Android interview must know 100 questions (interview questions + answer analysis)
China biodegradable plastics market forecast and investment strategy report (2022 Edition)
PHP实现敏感词过滤系统「建议收藏」
[2. Basics of Delphi grammar] 4 Object Pascal operators and expressions
Openlayers customize bubble boxes and navigate to bubble boxes
Official announcement! Hong Kong University of science and Technology (Guangzhou) approved!
Gameframework eating guide
剑指 Offer 20. 表示数值的字符串
What are the legal risks of NFT brought by stars such as curry and O'Neill?
[Verilog quick start of Niuke network question brushing series] ~ priority encoder circuit ①