arrays - How to create dynamic Map key in javascript? -


I have tried to create a map like the example below ...

  Var myMap = {"one": 1, "two": "two", "three": 3.0};   

Therefore, I repeat them to: (code of myMap) for {my>} {window.alert ("myMapmap property \ "" + Key + "\" = "+ map [key]); }

If my data is dynamic ... and I want to add each of them to the map ... how should the code be? And I hope the key is not stable ... I mean the data taken from other sources like the database, which was not previously defined.

  var data source = ...; Whereas (var o = dataSource.get ()) {myMap [o.key] = o.value; } (Var key in myMap) {alert ("key:" + "value:" + myMap [key]); }   

You can just type the object using an array such as syntax.

How and where you can get your data

Comments