problme with javascript map/object
- by akshay
I am using javascript map to store keys and values.Later on I check if specified key is present in map or not, but it sometimes gives correct result but sometimes it dont.I tried to print the map using console.log(mapname), it shows all keys, but i i try to check if some specified key is presnt sometimes it gives wrong answer.
Am using following code:
//following code is called n times in loop with different/same vales of x
myMap : new Object();
var key = x ; //populated dynamically actually
myMap[key] ="dummyval";
if(myIdMap[document.getElementById("abc").value.trim()]!=null)
alert('present' );
else
alert('not present');
What can be the possible problem?