.split() method without a separator, how does it work?

My question is about the .split() method on JavaScript, after reading this:

When we split string without providing a separator argument, for exemple:

const stringOfPeople = 'Dominic, Shelly, Luka, Devin';

const arrayOfPeople = stringOfPeople.split();


// Output: ['Dominic, Shelly, Luka, Devin']

Why is the output not:
[‘D’, ‘o’, ‘m’, ‘i’, ‘n’, ‘i’, ‘c’, ‘,’, ’ ', ‘S’, ‘h’, ‘e’, ‘l’, ‘l’, ‘y’, ‘,’, ’ ', ‘L’, ‘u’, ‘k’, ‘a’, ‘,’, ’ ', ‘D’, ‘e’, ‘v’, ‘i’, ‘n’]

Like the other example:

 const letters = 'abcde';

const lettersArray = letters.split('');

// Output: ['a', 'b', 'c', 'd', 'e']


I think that the default is that it just makes a copy of the string and puts it in an array if there’s no argument for the separator. [MDN reference]

1 Like

Hmm I see now the difference. The second example has quotes (even though there is nothing inside the quotes).

Thank you for enlightening me!

you forgot to write quotes inside the split parantheses .split()
so it should be wroten like this: .split(’’)