SYNTAX – str.split(separator, upto)
separator – A string or any expression which is used for splitting. It is optional. If in any case omitted, it will return an array of original strings.
- upto – It is a non-negative integer that decides the number of splits. Items after upto are excluded. An array may contain lesser entries than upto if the end of the string is reached before the limit is reached. If upto is 0 return .
For example –
Split a string into characters
const arr = str.split(“”);
Use any letter as a separator:
const arr = str.split(“o”);
If the separator parameter is omitted/not given
const arr = str.split();