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 don’t. I tried to print the map using console.log(mapname), it shows all keys, but if I try to check if some specified key is present – 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? Can alphanumericstring/integers values can be used as keys?
I think you have to store keys in some temporary table or objects like session or cookies for future retrieve.
you have dynamically store x position value in mymap[key] but every time it loads and overwrite your new values. you something doing wrong there..