The Split function method in JavaScript is to split a string into substrings and then return the result as an array of strings. How to use:
stringObj.split( [separator[, limit]])
Where stringobj is a required option. The String object or text to be exploded. The object is not modified by the split method.
Separator is optional. A string or regular expression object that identifies whether one or more characters are used to delimit a string. If this option is omitted, an array of single elements containing the entire string is returned.
Limit is optional. This value is used to limit the number of elements returned in an array.
The result of the split function is an array of strings, where each occurrence of separator in the stingobj is decomposed. Separator is not returned as part of any array element.
The following example shows the use of the Split function method in JavaScript.
function SplitDemo(){
var s, ss;
var s = "The rain in Spain falls mainly in the plain.";
// 在每个空格字符处进行分解。
ss = s.split(" ");
return(ss);
}