Huh. Sounds impossible, since there's no way to tell whether the chain has changed without checking.
But, meh. Not sure how much of a gain that would have been anyway.
That article seems to be entirely about object properties.
I agree that not reassigning a variable can help optimizations; I’m reasonably sure that you don’t need to use const for that tho. I love const, so I’d love to be wrong.
Yes, I think for optimization, "not reassigning" is identical to using const. I hope that when programmers have to decide between let, var, and const, they will be more attracted to code that only uses variable reassignment when it is actually necessary. I think that code, on average, would optimize to something faster.
However, unnecessary reassignment might be compiled into expressions anyway. I don't really know. Maybe someday I will have time to read V8's source.
feel free to mark this off-topic, but i'm not a fan of const. like predicting the shape of classes, web-devs like me are terrible at predicting whether a variable should be constant or mutable when fleshing out whatever ux-driven-feature we're hired to do.
const creates needless code-churn/tech-debt when i frequently need to "re-mutify" things during ux-code-rewrites, when i should've just used var or let for everything from the start.
Well, I 100% agree on "predicting the shape of classes". I think it's impossible.
And I love const, but this thing...
I haven't encountered the problem you're describing, but I do tend to cause bugs by typing const without thinking. (I use mostly functional programming, and const is just a natural fit when everything is immutable anyway.)
After this thread and looking into JS optimization a little, I would recommend not using const unless you feel it is improving your code and development process. (If your linter requires it, you have my sympathies!)
As far as optimizations go in general, I think this is on-topic. Optimizations should be offered to developers, not forced on us. But what the spec offers, employers might require. Changes might not be as optional as they seem.
Also, I think we've established that property lookups do not need to be optimized via a dedicated operator, so this thread's question is resolved.