I'm trying to dynamically populate a HashMap in jQuery, and am following this example: https://stackoverflow.com/a/4247012/1005607 Orig Question: How to create a simple map using JavaScript/JQuery
I need to add a hash entry where the key comes from an array item, and the value is a variable. But I'm getting an error. What's wrong? This should be equivalent to populating "item2" -> 2
in the HashMap. I would be able to get 2
by invoking laneMap.get("item2")
.
var laneMap = {};
var eventIDs = [];
eventIDs.push('item1');
eventIDs.push('item2');
var currlane = 2;
laneMap.push({eventIDs[1] : currlane });