I have a list of a few thousand integer keys. The only thing I need to do with this list is say whether or not a given value is in the list.
For C# I would use a
Under the hood, the JavaScript Object is implemented with a hash table.
So, your Key:Value pair would be (your integer):true
A constant-time lookup function could be implemented as:
var hash = {
1:true,
2:true,
7:true
//etc...
};
var checkValue = function(value){
return hash[value] === true;
};
checkValue(7); // => true
checkValue(3); // => false