js method to split string
Applicable to each scene is different
const arr = [ '1-2' , '1-3' , '2-3' , '3-4' ] ;
1. string.split()
Separated by special characters
'1-2' . split ( '-' ) // ['1', '2']
2. String.substring(start,stop)
start is required. A non-negative integer specifying the position in string of the first character of the substring to extract.
stop is optional, a non-negative integer, the header does not include the end, and it needs to add 1 to the last target number of characters.
'hello' . substring ( 1 , 3 ) // 'el'
…
The post js methods for splitting strings first appeared on Lenix Blog .
This article is reprinted from https://blog.p2hp.com/archives/9655
This site is for inclusion only, and the copyright belongs to the original author.