Thursday, October 13, 2011

Map in Javascript

Source :

Map in Javascript

var output = {}; 

Sort of. That just creates an empty instance of a JavaScript Object. It's identical to:

var output = new Object();   

There really isn't any implementation of Map in JavaScript.

But... JavaScript objects can be assigned properties on the fly, so an Object acts a lot like a map.

For example, after declaring your variable as shown above, you could write: = 123;    

and now the object has a property named abc that contains the value 123.

The value can be retrieved with either of:  

No comments:

Post a Comment