Which operation has the best time complexity when working with JavaScript objects?
Finding a property by key (direct property access) has the best time complexity when working with JavaScript objects, generally O(1) or constant time. JavaScript objects are implemented as hash tables (dictionaries), which enable fast lookups by key. In contrast, operations like iterating through all properties are O(n), and checking if an object contains a specific value requires examining each property, making it O(n) as well. This is why using objects as lookup tables is a common performance optimization when you need to repeatedly check if a value exists in a collection.