split
The split
method is the opposite of join
. While join
combines the elements
of an array into a string, split
divides a string into an array. Like join
,
split
takes an optional argument: the delimiter. The delimiter is a string
along which split
divides the receiver string. Whatever string you use as the
delimiter will be omitted from the returned array. By default, the delimiter is
an empty space (' '
). The split
method does not modify the original string.