Open panzerdp opened 4 years ago
Comment written by Felix Sanz on 04/29/2020 20:26:05
2. Because block scope doesn't exist pre-ES2015.
Comment written by Dmitri Pavlutin on 05/01/2020 07:38:00
That's right :).
Comment written by Hitesh Kumar on 05/12/2020 11:49:52
There's one more scope gotchas. It's around try-catch block. :)
https://smellycode.com/catc...
Comment written by Dmitri Pavlutin on 05/12/2020 14:44:53
Thanks for sharing @smellycode:disqus.
Comment written by Masha I. Klachko-Blair on 05/19/2020 21:30:46
How do you run JS in ES2015 environment? Clearly, Chrome's Console is the older environment since this code doesn't produce error:
{
function hello() {
return 'Hello!';
}
}
hello();
Comment written by Dmitri Pavlutin on 05/20/2020 08:04:26
I run my snippets in NodeJS v13.
greet function in the last question actually runs without throwing a ReferenceError, tested here https://replit.com/@basantsoni/SillyGhostwhiteScreencast#index.js
it should be scoped to the enclosing scope(global in this case)
Written on 04/24/2020 15:46:05
URL: https://dmitripavlutin.com/javascript-scope-gotchas/