Sunday, August 21, 2011

Creating a Map like data structure in java script

While I was working in one of my projects (GSoC 2011 - Sakai CLE mobile app) I wanted to have a map like data structure in java. Just for the clarity I will explain my scenario:

I have a list of items that I am being iterated over it and doing some stuff. So what I wanted is to have store some dynamic values on the fly as key:value pairs. I am actually new to Java Script and I am not sure this a good way and I appreciate if anyone can share any other possible ways. Here is what I did:



Output:

key1: val1
key2: val2
.
.
keyn: valn

Correct me if this is wrong or not the efficient way!