JavaScript - Block Scope
http://www.digital-web.com/articles/scope_in_javascript
http://www.sitepoint.com/demystifying-javascript-variable-scope-hoisting/
A block is a set of statements wrapped in curly braces. Unlike many other
languages, blocks in JavaScript do not create a new scope. In fact, all variables
and functions are hoisted to the top of the function that they are declared in,
and this may create problem / confusion. See a separate page for problems
related to hoisting.
JavaScript does not have a concept of "block scope". Blocks in JavaScript do
not create new scopes. A block is a set of statement wrapped in curly braces.
Unlike many other languages, blocks in JavaScript do not create a new scope, so
variables should be defined at the top of the function, not in blocks.
See "JavaScript: The Good Parts" by Douglas Crockford, page 10.
page revision: 2, last edited: 25 Nov 2021 07:27