problme with javascript map/object

Posted by akshay on Stack Overflow See other posts from Stack Overflow or by akshay
Published on 2011-01-12T04:28:48Z Indexed on 2011/01/12 4:53 UTC
Read the original article Hit count: 175

Filed under:

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?

© Stack Overflow or respective owner

Related posts about JavaScript