How to use hashmap in javascript
I have a hash map I want to use it in javascript. So I thought of converting it in开发者_StackOverflow社区to javascript map..how to use it or to do?
Turn it into an object literal...
var map = {
'a' : 'a',
'b': 'b'
...
};
Or use Associative Arrays, for example:
var arr = new Array();
arr["One"] = 1;
arr["Two"] = 2;
arr["Thr"] = 3;
arr["For"] = 4;
for(var i in arr)
{
alert('Key='+i + ', Value = '+arr[i]);
}
精彩评论