String.prototype.split

Split a string into substrings using the specified separator and return them as an array.

Syntax

split(separator, limit?)

Parameters

Return value

An array of strings.

Examples

"coffee/tea/milk".split("/")
["coffee", "tea", "milk"]
"coffee,tea,milk".split(",", 2)
["coffee", "tea"]
"Sum 41 band".split(/\d/)
["Sum ", "" ," band"]
`one
two  three
four`.split(/\s+/)
["one", "two", "three", "four"]