Originally posted by Mark Hughes:
I was told a map can be declared as
Sort of. That just creates an empty instance of a JavaScript Object. It's identical to:
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:
and now the object has a property named abc that contains the value 123.
The value can be retrieved with either of:
which are completely equivalent.
So in short, there is no Map in JavaScript, but you can use a JavaScript Object instance in a manner very similar to what we think of as a Map in Java.
[ November 22, 2007: Message edited by: Bear Bibeault ]