当前位置:网站首页>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
边栏推荐
- The reviewboard has 500 errors when submitting a review. Solutions
- vulnhub靶场-Hacker_Kid-v1.0.1
- Reflective XSS vulnerability
- Development cost of smart factory management system software platform
- China acetonitrile market forecast and strategic consulting research report (2022 Edition)
- LeetCode中等题之TinyURL 的加密与解密
- 中国茂金属聚乙烯(mPE)行业研究报告(2022版)
- From comedians to NBA Zhan Huang, check the encrypted advertisements during this super bowl
- JDBC:深入理解PreparedStatement和Statement[通俗易懂]
- People help ant help task platform repair source code
猜你喜欢
Replace UUID, nanoid is faster and safer!
The new server is packaged with the source code of H5 mall with an operation level value of several thousand
Gold, silver and four want to change jobs, so we should seize the time to make up
Kia recalls some K3 new energy with potential safety hazards
Penetration practice vulnhub range Keyring
Intelligent operation and maintenance practice: banking business process and single transaction tracking
Htt [ripro network disk link detection plug-in] currently supports four common network disks
[PHP foundation] realize the connection between PHP and SQL database
Integer array merge [JS]
(十六)ADC转换实验
随机推荐
官宣!香港科技大学(广州)获批!
Report on research and investment prospects of UHMWPE industry in China (2022 Edition)
Countdownlatch blocking wait for multithreading concurrency
整形数组合并【JS】
[mathematical modeling] [matlab] implementation of two-dimensional rectangular packing code
ACM mm 2022 video understanding challenge video classification track champion autox team technology sharing
China metallocene polyethylene (MPE) Industry Research Report (2022 Edition)
Software construction scheme of smart factory collaborative management and control application system
How to write good code - Defensive Programming Guide
The reviewboard has 500 errors when submitting a review. Solutions
How to use JMeter function and mockjs function in metersphere interface test
SLO is increasingly used to achieve observability | Devops
线上开通ETF基金账户安全吗?有哪些步骤?
2022 Heilongjiang latest fire protection facility operator simulation test question bank and answers
[C supplement] [string] display the schedule of a month by date
麦趣尔:媒体报道所涉两批次产品已下架封存,受理消费者诉求
Is the software of futures pioneer formal and safe? Which futures company is safer to choose?
[wrung Ba wrung Ba is 20] [essay] why should I learn this in college?
transform. Forward and vector3 Differences in the use of forward
Research Report on development prediction and investment direction of nylon filament sewing thread in China (2022 Edition)