开发者

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


Use dataset[i].properties[myVar] == 'value'.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜