I want to create a map object in javascript. I came to the following idea:
var a = new Array();
a["key1"] = "value1";
a["key2"] = "value2";
but then how I can find if a particular key exists or not?
Don't use an array if you want named keys, use a plain object.
var a = {};
a["key1"] = "value1";
a["key2"] = "value2";
Then:
if ("key1" in a) {
// something
} else {
// something else
}