4 ms·
To be fair; getting the benefit of const would require code too though: function constUseful () { var guarded = 1; (function loop (orgGuarded) {
by shawndumas 11y ago
To be fair; getting the benefit of const would require code too though:
function constUseful () {
var guarded = 1;
(function loop (orgGuarded) {
setTimeout(function () {
if (guarded !== orgGuarded) {
throw 'guarded reassigned!';
}
loop(orgGuarded);
}, 0);
})(guarded);
guarded = 2;
}
constUseful();
That's an approximation of const's value as delineated in code.