It's a completely empty object (nothing inherited from any .prototype
including Object.prototype
), so you can be guaranteed that any property lookup will only succeed if the property was explicitly added to the object.
For example, if you want to store some data where you won't know the keys in advance, there's a possibility that a provided key will have the same name as a member of Object.prototype
, and cause a bug.
In those cases, you need to do an explicit .hasOwnProperty()
check to rule out unexpected inherited values. But if there's nothing inherited, your testing can be simplified to a if (key in my_object) {
test, or perhaps a simple truthy test if (my_object[key]) {
if appropriate.
Also, with no prototype chain, I would imagine that lookups of properties that turn out to not exist would be faster, since only the immediate object would need to be checked. Whether or not this pans out in reality (due to optimizations) would be determined with performance testing.