Skip to content

Commit

Permalink
Add valid example that shows vars in a block scope
Browse files Browse the repository at this point in the history
All the current valid examples show hoisting the var to the function scope. This example makes is clear that this rule allows you to declare vars inside a block scope, just not use them out of that scope.
  • Loading branch information
edg2s committed Mar 18, 2021
1 parent ebd7026 commit fc835c1
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions docs/rules/block-scoped-var.md
Expand Up @@ -71,6 +71,13 @@ function doTryCatch() {
f = build;
}
}

function doFor() {
for (var x = 1; x < 10; x++) {
var y = f(x);
console.log(y);
}
}
```

## Further Reading
Expand Down

0 comments on commit fc835c1

Please sign in to comment.