Jsref Split
# JavaScript split() Method
[ JavaScript String Object](#)
## Example
Split a string into an array using a space as the separator:
var str = "How are you doing today?";
var n = str.split(" ");
The result of _n_ is:
["How","are","you","doing","today?"]
[Try it Β»](#)
* * *
## Definition and Usage
The `split()` method is used to split a string into an array based on a specified separator.
**Tip:** If an empty string `("")` is used as the separator, the string will be split into an **array of individual characters**.
**Note:** `split()` does not modify the original string; it returns a new array.
* * *
## Browser Support
!(#)!(#)!(#)!(#)!(#)
The `split()` method is supported by all major browsers.
* * *
## Syntax
_string_.split(_separator_, _limit_)
## Parameter Values
| Parameter | Description |
| --- | --- |
| _separator_ | Optional. A string or regular expression that specifies the split points. For example: `" "` (space), `","`, `/d/`, etc. |
| _limit_ | Optional. Limits the maximum length of the returned array. If this parameter is set, the number of elements in the result array will not exceed this value. |
## Return Value
| Type | Description |
| --- | --- |
| Array | Returns an array of strings. The string is split at the positions specified by _separator_, and the result **does not include the separator itself**. |
## Technical Details
| JavaScript Version: | 1.1 |
| --- |
* * *
## More Examples
## Example
No separator provided:
var str = "How are you doing today?";
var n = str.split();
The result of _n_ is (no splitting occurs):
["How are you doing today?"]
[Try it Β»](#)
## Example
Split by each character (including spaces):
var str = "How are you doing today?";
var n = str.split("");
The result of _n_ is:
["H","o","w"," ","a","r","e"," ","y","o","u"," ","d","o","i","n","g"," ","t","o","d","a","y","?"]
[Try it Β»](#)
## Example
Use `limit` to restrict the number of results:
var str = "How are you doing today?";
var n = str.split(" ", 3);
The result of _n_ is:
["How","are","you"]
[Try it Β»](#)
## Example
Use a specific character as the separator:
var str = "How are you doing today?";
var n = str.split("o");
The result of _n_ is:
["H","w are y","u d","
YouTip