From http://www.w3schools.com (Copyright Refsnes Data)
JavaScript String Object
The split() method is used to split a string into an array of substrings, and returns the new array.
| stringObject.split(separator, limit) |
| Parameter | Description |
|---|---|
| separator | Optional. Specifies the character to use for splitting the string. If omitted, the entire string will be returned |
| limit | Optional. An integer that specifies the number of splits |
Tip: If an empty string ("") is used as the separator, the string is split between each character.
ExampleSplit a string in different ways:
The output of the code above will be:
Try it yourself » |
JavaScript String Object
From http://www.w3schools.com (Copyright Refsnes Data)