JavaScript String split()
Example
Split a string into an array of substrings:
let str = "How are you doing today?";
const myArr = str.split(" ");
Try it Yourself »
More "Try it Yourself" examples below.
Definition and Usage
The split() method splits a string into an array of substrings, and
returns the new array.
If an empty string ("") is used as the separator, the string is split between each character.
The split() method does not change the original string.
Browser Support
split() is fully supported in all browsers:
| Chrome | IE | Edge | Firefox | Safari | Opera |
| Yes | Yes | Yes | Yes | Yes | Yes |
Syntax
string.split(separator, limit)
Parameter Values
| Parameter | Description |
|---|---|
| separator | Optional. Specifies the character, or the regular expression, to use for splitting the string. If omitted, the entire string will be returned (an array with only one item) |
| limit | Optional. An integer that specifies the number of splits, items after the split limit will not be included in the array |
Technical Details
| Return Value: | An Array, containing the splitted values |
|---|---|
| JavaScript Version: | ECMAScript 1 |
More Examples
Example
Separate each character, including white-space:
const myArr = str.split("");
Try it Yourself »

