3 ms·
It's deeply aesthetically offensive, for one. It's error-prone, for two: if False: p = 1 print p No, thank you.
by trhtrsh 14y ago
It's deeply aesthetically offensive, for one. It's error-prone, for two:
if False:
p = 1
print p
No, thank you.
- reissbaker 14y agoThat's not how function-level scoping works in Javascript. function p() { if(false) var p = 10; return p; } p(); // evaluates to undefined What you'd get in a block-scoped language is some sort of ReferenceError; you still don't get 10 in JS, though. The variable is accessible outside of the block, but the block itself isn't executed. The above is just equivalent to the following transformation: function p() { var p; if(false) p = 10; return p; } p(); Aesthetic offense is a matter of taste. I prefer Scheme over C for aesthetic beauty, but many prefer the opposite.