In some of the projects I'm working on as part of my day job, I need to access data in very large JS objects (on the order of thousands of key-value pairs). I'm trying to improve the efficiency of my code, so I came up with a few questions:
- What is the runtime complexity of JS when accessing a field in such an object? My initial hunch is that it's O(n)
- Is there a difference when accessing through dot notation or bracket notation? (e.g.
obj.field
vsobj[field]
) - I'm guessing there is a different answer for different runtime engines - is there a place where I can see the difference between them?