JavaScript String Reference Previous Next JavaScript Strings. A JavaScript string stores a … If separator is omitted, the array returned contains one element consisting of the entire string. …
The default separator is comma (,). The split() method is used to split a string into an array of substrings, and returns the new array. Definition and Usage. str.split() function is used to split the given string into array of strings by separating it into substrings using a specified separator provided in the argument. The join() method returns the array as a string.. The elements will be separated by a specified separator.
string.split([separator][, limit]); Argument Details. Split a string into an array of substrings: var str = "How are you doing today? "; var res = str.split(" "); Try it Yourself » More "Try it Yourself" examples below. separator − Specifies the character to use for separating the string. Invoke the split method on the string you want to split into array elements. limit − Integer specifying a limit on the number of splits to be found. JavaScript String split() Method Previous JavaScript String Reference Next Example. Definition and Usage. JavaScript's string split method returns an array of substrings obtained by splitting a string on a separator you specify. Return Value.
The separator can be a string or regular expression. The syntax of the function is as follows: str.split(separator, limit) Arguments The first argument to this function is a string which specifies the points where the split has to take place.