I understand that Javascript objects are flexible enough that they can imitate the common hash array functionality (keys as strings, values as primitive types, able to loop by keys/values)...
I have this example and I can't figure out why it doesn't work:
var hash = {
'a' : '',
'b' : '',
'c' : '',
}
One of those values gets initialized like so:
hash['a'] = 5;
Then I try to loop through them:
var keys = Object.keys(hash);
for(var i in keys){
console.log(hash[i]);
}
The result is 3 'undefined'.
Why is this happening?
