如果我有一个看起来像这样的数组;
markers[56] = { label: "One" };
markers[62] = { label: "Two" };
markers[87] = { label: "Three" };
markers[125] = { label: "Four" };
现在我有一些JS;
for (var thisMarker in markers) {
//What goes here so I can access the "label" property?
}
我知道这很简单但后来会有更多属性添加到对象而不仅仅是“标签”。
答案 0 :(得分:4)
我相信你可以像这样访问它,
for (var thisMarker in markers) {
alert(markers[thisMarker].label);
}
答案 1 :(得分:0)
for(var thisMarker in markers){
//this will give you the label- markers[thisMarker].label
}