Skip to content

Instantly share code, notes, and snippets.

@eshacker
Created January 26, 2016 12:53
Show Gist options
  • Save eshacker/caaa9d198d6433b4f9d3 to your computer and use it in GitHub Desktop.
Save eshacker/caaa9d198d6433b4f9d3 to your computer and use it in GitHub Desktop.
Quick split() check
console.log("1,2,3,4".split(''))
["1", ",", "2", ",", "3", ",", "4"]
console.log("1,2,3,4".split(','))
["1", "2", "3", "4"]
console.log("1,2,3,4".split())
["1,2,3,4"]
console.log("1 2 3 4".split())
["1 2 3 4"]
console.log("1,2,3,4".split(' '))
["1,2,3,4"]
console.log("1 2 3 4".split(' '))
["1", "2", "3", "4"]
`split()` is as useless as they come. Converts a string to an array containing single string.
`split('')` is same as `split(' ')`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment