Block scoping variables
Block scoping is used mostly as by-product of using the standard blocks like try-catch, if-then, do-while etc.
However you can explicitly use blocks by unqualified { } braces. I've started using this feature to contain the variables within a function to a specific scope. This is cutting down silly mistakes during development time.
Comments
- Anonymous
December 02, 2008
PingBack from http://blog.a-foton.ru/index.php/2008/12/03/block-scoping-variables/ - Anonymous
December 02, 2008
Good suggestion. I will start using this right away - Anonymous
December 03, 2008
The comment has been removed - Anonymous
December 12, 2008
the ecma script does look more elegant.the basic problem with unnamed blocks is that in most cases it can be used to identify code that should be separated out in a different function.I am currently using it as a development time helper with an eye to re factor these out if possible