Following the example from: How is a JavaScript hash map implemented? I want to know whether this is the most optimized way of getting an element from an object:
var obj = {
foo:{ hi: "higher"},
bar:{ bye: "bye"},
baz:{ cya: "cya"}
}
var value = obj[Object.getOwnPropertyNames(obj)[0]];
console.log(value);
I just need the most optimized way to get an element (random is fine, just need any one element in the object) from a given object, it does not matter which it is. I just need access to it and want to be able to delete it.
Is this the best implementation ?