In JavaScript, the split function divides a string into substrings and returns the result as a string array. Usage: stringObj. split ([separator [, limit]) Where stringObj is required. String object or text to be decomposed. This object will not be modified by the split method. Separator is optional. In JavaScript, the split function divides a string into substrings and returns the result as a string array. Usage: stringObj. split ([separator [,
Limit])
StringObj is required. String object or text to be decomposed. This object will not be modified by the split method.
Separator is optional. A string or regular expression object that identifies whether a string is separated by one or more characters. If this option is ignored, a single array of elements containing the entire string is returned.
Limit is optional. This value is used to limit the number of elements in the returned array.
The result of the split function is a string array. In stingObj, the position where separator appears must be decomposed. The separator is not returned as part of any array element.
The following example demonstrates the use of the split function in JavaScript.
Function SplitDemo (){
Var s, ss;
Var s = "The rain in Spain falls mainly in theplain .";
// Separate each space character.
Ss = s. split ("");
Return (ss );
}