Laxmidi
Laxmidi

Reputation: 2684

Basic Javascript Concatenation Question

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?

Upvotes: 0

Views: 106

Answers (1)

jondavidjohn
jondavidjohn

Reputation: 62392

google.maps.MapTypeId[args.type];

To dynamically call object properties you can use this syntax.

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

Upvotes: 1

Related Questions