The string to split
The separator the values are broken at, either as a literal string or as a pattern; defaults to
/\s+/u, a run of whitespace
A new array holding the values string names, in order, each with every run of whitespace replaced by a
single space and the outer whitespace dropped, the empty ones left out; empty if string names no value
Splits a string into tidied, non-empty values.
Breaks a string at every separator match and reports the values sitting between the matches, each tidied as tidy does and the empty ones dropped, so that a list written for a human reader, with the spacing and the stray separators that entails, is read as the values it names.
By default, values are taken to be separated by whitespace, breaking at the blanks and the line terminators alike, however many of them the layout inserted, so that a bare call reads a list carrying no separator of its own; supply a separator to read a list that marks its values some other way, a comma among them.
Whitespace is the set ECMAScript recognises: the ASCII blanks and line terminators, the no-break space, the Unicode space separators and the byte order mark.
A string separator is matched literally, so characters a pattern would read as syntax need no escaping; a pattern carrying capture groups contributes what it captures to the result, as
String.prototype.splitdoes.