Re:Fundamentals of Optimal Code Style
by qayxc on Thursday March 25, 2021 @08:00PM
(#26587263)
Not just in Javascript. Since blocks define a scope, visibility and unexpected lifetime issues may occur in other curly-braces languages like C and C++ just as well.
Using blocks like that is something you should be very careful about - might have some surprising effects especially for novice programmers.
Re:Fundamentals of Optimal Code Style
by twic on Friday March 26, 2021 @05:43AM
(#26590268)
The blocks here act exactly the same as any other blocks, like the ones you write for loops and ifs etc. So i wouldn't exactly call the consequences "unexpected".
Using blocks like that is something you should be very careful about - might have some surprising effects especially for novice programmers.