Odd error in Safari: <script> { const myValue = 'abc'; function logMyValue() { console.log(myValue); // ReferenceError: Can't find variable: myValue } logMyValue(); } </script>
-
-
I think this is because we are still using old Function-Statement evaluation: function-declaration in ECMA262 5th was only allowed in global space in the spec, and we were handling this type of thing as function-statement, which can be in braces, but interpreted as function-decl.
-
Then, what is going on is this function's scope is under global scope, as if it is declared as a function-declaration in the global scope instead of block scope. maybe, only in block scope in global code (Program).
- 1 more reply
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.
JavaScript, HTML, CSS, HTTP, performance, security, Bash, Unicode, i18n, macOS.