I had an array with a large amount of values that I was iterating over to find a specific value like this:
function haveValue(value) {
for(var index in arr) {
var prop = arr[index];
if(prop === value) {
return true;
}
}
return false;
}
But it occurred to me that I could possibly perform this lookup much more quickly by using an object:
function haveValue(value) {
return typeof obj[value] !== 'undefined';
}
However, I have not seen much of an improvement in performance after doing this. So I'm wondering, how are object properties stored in Javascript/Node.js? Are they basically iterated over in order to find, the same as an array? I thought they might be implemented using a hash table or something.