I think creating objects with Object.create(null)
generally unnecessary and not worth the browser compatibility and clarity you sacrifice. When you create an object with the {}
syntax you are essentially doing Object.create(Object.prototype)
, which creates an object with access to the properties in Object.prototype
. This means that you have access to methods like toString
and hasOwnProperty
directly from the object, but can also override them if you want — although you should avoid this if possible. As for performance, the difference is very small with only two properties on the object (as demonstrated on jsperf). If your object had hundreds or thousands of properties the difference would be almost nonexistent.
In conclusion, if you wan't your code to perform better you should always strive for clarity and try to improve the high level, algorithmic design of your code (not that you haven't already); and only worry about micro-optimizations only when absolutely necessary.