[英]How to evaluate var Array in nodejs, at client side?
The statement 该声明
- var X = [ "a", "b", "c"]
when evaluated using #{X}
converts X
it into string "a, b, c". 使用#{X}
进行评估时,会将X
转换为字符串“ a,b,c”。
how to evaluate X without converting it into String? 如何计算X而不将其转换为String?
Note: i'm using a bootstrap plug in which demands an Array as input. 注意:我使用的是自举插件,其中需要使用Array作为输入。
<input data-source='["a", "b", "c"]' >
Here I am trying to substitute the above array with X
. 在这里,我试图用X
代替上面的数组。 But like mentioned above, the #{X}
operation converts it into a sting, rather than deliver an array to data-source
. 但是如上所述, #{X}
操作将其转换为字符串,而不是将数组传递给data-source
。
使用JSON.stringify()
将数组转换为JSON /字符串表示形式:
var X = JSON.stringify( [ "a", "b", "c"] ); // yields '["a", "b", "c"]'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.