开发者

Basic Javascript Concatenation Question

开发者 https://www.devze.com 2023-04-05 05:45 出处:网络
I need some help with concatenating in Javascript. I\'ve开发者_高级运维 got an array. The value of:

I need some help with concatenating in Javascript.

I've开发者_高级运维 got an array. The value of:

(args['type'])

is TERRAIN.

In another array, I've got:

var myOptions = {
    zoom: parseInt( args['zoom'] ),
    center: latlng,
    mapTypeId: 
  };

I want to set mapTypeId to google.maps.MapTypeId.TERRAIN (using whatever value is held in args['type'] instead of hardcoding TERRAIN ).

How do I concatenate it in this situation?


google.maps.MapTypeId[args.type];

To dynamically call object properties you can use this syntax.

args.type and args['type'] are functionally identical.

0

精彩评论

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

关注公众号