Home > Web Front-end > JS Tutorial > Instructions on how to use split function in js_javascript skills

Instructions on how to use split function in js_javascript skills

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-05-16 17:06:57
Original
1646 people have browsed it

split
split is the opposite of join and is used to split a string into a string array.
stringObject.split(a,b) This is Its syntax.

a is required. Decide to split from a.
b is not required, it is optional. This parameter specifies the maximum length of the returned array. If this parameter is set, no more substrings will be returned than the array specified by this parameter. If this parameter is not set, the entire string will be split regardless of its length.

Note that a itself is not included in the returned array;

Tips and Notes
Note: If an empty string ("") is used as a, stringObject will be split between each character.
Note: The operation performed by String.split() is the opposite of the operation performed by Array.join.

Example
var str="Hello World!";
document.write(str.split("") "
");
document .write(str.split(" ") "
");
document.write(str.split("",3) "
");

Return
H,e,l,l,o, ,W,o,r,l,d,!
Hello,World!
H,e,l

Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
Where is js written?
From 1970-01-01 08:00:00
0
0
0
js addClass not working
From 1970-01-01 08:00:00
0
0
0
js file code not found
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template