May 2008
Intermediate to advanced
172 pages
4h 54m
English
In many languages, a block introduces a scope. Variables introduced in a block are not visible outside of the block.
In JavaScript, blocks do not introduce a scope. There is only function-scope. A variable introduced anywhere in a function is visible everywhere in the function. JavaScript's blocks confuse experienced programmers and lead to errors because the familiar syntax makes a false promise.
JSLint expects blocks with function, if, switch,
while, for, do, and try statements and nowhere else. An exception is made for an
unblocked if statement on an else or for
in.