Why can let declare variables repeatedly in the browser console?
I remember that I would have reported an error before. Is 21-year chrome based on that ECMA-specification?
let a=1
undefinedlet a=12
undefinednavigator.userAgent
'Mozilla/5.0 (Windows NT 10.0; Win64; x64)
AppleWebKit/537.36 (KHTML, like Gecko) Chro
me/93.0.4577.82 Safari/537.36'
Here's a screenshot:
The console environment has a number of odd quirks. It's not like a standard <script> tag on the page.
One of the quirks is these. The way it used to be in Chrome was, re-declarations of variables with let was not permitted - you'd get the expected error that the re-declaration is invalid syntax. But as of Chrome 80 or so (spring 2020), it was changed to be permitted.
You still can't re-declare variables with let in a standard <script>, of course:
let foo = 5;
let foo = 10;
You cannot redeclare a variable previously declared with let in strict mode. Please see: What's the difference between using "let" and "var"?.