// JavaScript hashmap equivalent var key = function(obj){ // Some unique object-dependent key return obj.totallyUniqueEmployeeIdKey; // Just an example }; var dict = {}; dict[key(obj1)] = obj1; dict[key(obj2)] = obj2;