I have a space separated string that I want to make into an array. I am using the .split(' ') method to do this. Will the resulting array have those spaces in it? For example if my string is "joe walked down the street" and I performed the method on it would the array look like this ["joe", "walked", "down", "the", "street"] or will it look like this ["joe ", "walked ", "down ", "the ", "street "]?
I have a space separated string that I want to make into an array.
Share
Nope, it would not have the spaces in there. It would look like this:
Since spaces are a bit hard to see, let’s take a more visible example with the same effect:
You can test it here.