> For the complete documentation index, see [llms.txt](https://huang-jason.gitbook.io/js-syntax/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://huang-jason.gitbook.io/js-syntax/block-level_scope.md).

# block-level scope

```javascript
for (var i = 0; i < 10; i++) {
  /* ... */
}
console.log(i);  // what will this output?
```

should be `undefined` for other languages, but `10` for JS.

## variable hoisting

Variable `i` remains in scope even after the for loop has completed, retaining its last value after exiting the loop.

## `let`

The support for **block-level scopes** is available for the new `let` keyword.
