How can I convert a string to a JavaScript array?
(如何将字符串转换为JavaScript数组?)
Look at the code:
(看看代码:)
var string = "0,1";
var array = [string];
alert(array[0]);
In this case, alert
would pop-up a 0,1
.
(在这种情况下, alert
会弹出一个0,1
。)
0
, and when alert(array[1]);
(当它是一个数组时,它会弹出一个0
,当alert(array[1]);
)
1
. (被叫,它应该弹出1
。)
Is there any chance to convert such string into a JavaScript array?
(有没有机会将这样的字符串转换为JavaScript数组?)
ask by Scott translate from so