3 ms·
Is this still true on modern browsers with optimising js engines? And if so, why?
by gillespie 14y ago
Is this still true on modern browsers with optimising js engines? And if so, why?
- firefoxman1 14y agoWell, according to this answer (http://stackoverflow.com/a/7701264 http://stackoverflow.com/a/7701264) V8 is about the same speed as accessing variables, however I would bet looking up properties higher up the prototype chain would take a performance hit.
- gillespie 14y agoI was thinking more that if you repeatedly access a property, regardless of where in the prototype chain it is, the optimiser would cache the value, so it would be equivalent to saving it in a local variable. If I'm not mistaken, this is a common feature in optimizing compilers. I don't know how aggressive the JIT js compilers are, however.
- firefoxman1 14y agoHmm that's pretty interesting. I don't really like to depend on the engine for optimizations because you never know what JS engine people have, but it's good to know they do that.