[英]Javascript: Proper syntax with arrays?
Accessing an array element with the following line works great; 使用以下行访问数组元素非常有用;
if (dataset[i].properties.property == "value") { ...
However when I want to make it a tad more dynamic, I get stuck. 但是,当我想使其更具动态性时,我会卡住。 How can I use my own variable to access the array element, as shown below? 如何使用我自己的变量访问数组元素,如下所示?
var myVar = 'property';
if (dataset[i].properties.myVar == "value") { ...
Thanks 谢谢
使用dataset[i].properties[myVar] == 'value'
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.