1 # Treat var as Block Scoped (block-scoped-var)
3 The `block-scoped-var` rule generates warnings when variables are used outside of the block in which they were defined. This emulates C-style block scope.
7 This rule aims to reduce the usage of variables outside of their binding context and emulate traditional block scope from other languages. This is to help newcomers to the language avoid difficult bugs with variable hoisting.
9 Examples of **incorrect** code for this rule:
12 /*eslint block-scoped-var: "error"*/
30 function doTryCatch() {
39 Examples of **correct** code for this rule:
42 /*eslint block-scoped-var: "error"*/
64 function doTryCatch() {
78 * [JavaScript Scoping and Hoisting](http://www.adequatelygood.com/JavaScript-Scoping-and-Hoisting.html)
79 * [var Hoisting](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/var#var_hoisting)