tags:

views:

35

answers:

2

I seen this code

a=a.join("").split("");

What does this code do? I think a was a string array, but is it still a string array? does this filter out values? what does it do?

A: 

it creates a copy of the array, dunno why it is assigned to the same variable

TheBrain
+7  A: 

a is still a string array, but is an array of characters.

                   a == ["foo", "", "", "bar", "baz"]
          a.join("") == "foobarbaz"
a.join("").split("") == ["f", "o", "o", "b", "a", "r", "b", "a", "z"]

I don't know the purpose of this code.

KennyTM