I typically use the following code in JavaScript to split a string by whitespace.
\"The quick brown fox jumps over the lazy dog.\".split(/\\s+/); // [\"The\"
Instead of splitting at whitespace sequences, you could match any non-whitespace sequences:
" The quick brown fox jumps over the lazy dog. ".match(/\S+/g)