4 ms·
Note to onlookers: blocks can soemtimes act weird in javascript. I loved using them but alas.
by danlugo92 6y ago
Note to onlookers: blocks can soemtimes act weird in javascript. I loved using them but alas.
- qayxc 6y agoNot 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.
- twic 6y agoThe 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".
- danlugo92 6y agoI can't recall right now but I remember having errors that would not happen inside a normal for loop block. And I was using let/const not var.