how can I loop through these items?
var userCache = {};
userCache['john'] = {ID: 234, name: 'john', ... };
userCache['mary'] = {ID: 567, name: 'mary', ... };
userCache['douglas'] = {ID: 42, name: 'douglas', ... };
the length property doesn’t work?
userCache.length
You can loop over the properties (
john,maryanddouglas) of youruserCacheobject as follows:It is important to use the
hasOwnProperty()method, to determine whether the object has the specified property as a direct property, and not inherited from the object’s prototype chain.