4 ms·
How? You have to do some kind of check with let, and you don't with const.
by gfxgirl 6y ago
How? You have to do some kind of check with let, and you don't with const.
- miloignis 6y agoNot sure if V8 does this, but a general strategy used in HotSpot is to compile assuming the good case and install a "trap" to deoptimize the code if the condition is violated. So you could compile the let like a const with no checks on the use of the variable, but have a trap such that if any code ever tries to assign to that variable, all code compiled under the assumption that it was constant is throw out.