News for hackers. Stuff that matters.
Re:Using const/let instead of var can make JavaScript code r... by smt88 on Wednesday October 21, 2020 @12:42AM (#24844786)
JS is so ultra-optimized by modern browsers that we're going to run into cases like this. It's inevitable.

Hopefully they're always treated like bugs and not something we need to work around.

Re:Using const/let instead of var can make JavaScript code r... by olliej on Wednesday October 21, 2020 @03:18AM (#24845494)
The JSC team (and I suspect V8 and SM) always treat performance cliffs caused by normal/sensible code patterns as a bug.

The problem is that when implementing improvements it's easy to forget every mostly-equivalent thing and so miss obvious things (often the entire fix in the end is "if (canDoItFast) doTheExistingFastThing()"

Re:Using const/let instead of var can make JavaScript code r... by smt88 on Wednesday October 21, 2020 @10:01AM (#24847953)
I can imagine some workarounds for that. Go to GitHub and pull the tests for a few thousand libraries, and watch for major performance changes.

I mean I'm sure they have a solution, since this seems like a rare occurrence.

I will note though that const/let are not mostly equivalent to var. They're often used interchangeably, but they work pretty differently as far as a JS engine is concerned.