Skip to content

Commit

Permalink
Update files/en-us/web/javascript/reference/statements/var/index.md
Browse files Browse the repository at this point in the history
Co-authored-by: Joshua Chen <[email protected]>
  • Loading branch information
domleonard and Josh-Cena authored Jul 20, 2023
1 parent 69ccc90 commit 59780c5
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion files/en-us/web/javascript/reference/statements/var/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ The list that follows the `var` keyword is called a _{{glossary("binding")}} lis

### Hoisting

`var` declarations, wherever they occur, are processed during JavaScript compilation before any code is executed. Declaring a variable anywhere in the code is equivalent to declaring it at the top. This also means that a variable can appear to be used before it's declared. This behavior is called [_hoisting_](/en-US/docs/Glossary/Hoisting), as it appears that the variable declaration is moved to the top of the function or global code.
`var` declarations, wherever they occur in a script, are processed before any code within the script is executed. Declaring a variable anywhere in the code is equivalent to declaring it at the top. This also means that a variable can appear to be used before it's declared. This behavior is called [_hoisting_](/en-US/docs/Glossary/Hoisting), as it appears that the variable declaration is moved to the top of the function, static initialization block, or script source in which it occurs.

> **Note:** `var` declarations are only hoisted to the top of the current script. If you have two `<script>` elements within one HTML, the first script cannot access variables declared by the second one.
```js
bla = 2;
Expand Down

0 comments on commit 59780c5

Please sign in to comment.