Created
January 26, 2016 12:53
-
-
Save eshacker/caaa9d198d6433b4f9d3 to your computer and use it in GitHub Desktop.
Quick split() check
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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