3

I have this code in JS:

var array = ['one', 'two'];

And each time I want to display the array, it is displayed with like this:

one,two

Now my question is, is there any way to remove that nasty comma?

4

2 回答 2

13

To display them next to each other, you can use join. array.join(' ');

于 2012-07-24T18:34:54.393 回答
1

You could use the replace method of the string object:

array.toString().replace(',',' ')
于 2012-07-24T18:39:53.593 回答