Mozilla’s website clearly describes hasOwnProperty() and the in operator.
However, it does not give any implementation details in regards to their efficiencies.
I would suspect they’d be O(1) (constant time) but would love to see any references or tests that might exist.
To turn my comments into an answer.
hasOwnProperty()should beO(1), as it is a key lookup, but it will be implementation specific.inwill most certainly be more complicated (though should be the same ashasOwnProperty()if the property exists on that object), as it goes up the prototype chain, looking for that property. That is why it is often recommended to usehasOwnProperty()when iterating over object properties withfor ( in ).To find out, inspect the source code of these functions. Use the source, Luke 🙂