I have a json object, say box = {}; to which I will keep adding key-values like box['somename'] = somevalue. There may be repetitions of somename and I want the last instance’s value to win. All this is fine.
Now I need to operate on it, as if it were an array. Basically, now that I have a set of unique keys, I want one main operation box.length to see how many unique elements there are. Is there an elegant constant time way of doing it without iterating through all properties of this object?
1 Answer