mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-05-05 18:01:45 -04:00
fix(curriculum): typo in lecture the var keyword and hoisting (#59965)
This commit is contained in:
@@ -26,7 +26,7 @@ var x = 5;
|
||||
console.log(5); // 5
|
||||
```
|
||||
|
||||
In this code even though we use `x` before declaring it we don't get an error, instead we get `undefined`. This is because JavaScript hoists the declaration `var x` to the top of its scope but not the inialization `x = 5`. It's as if the code were rewritten like this:
|
||||
In this code even though we use `x` before declaring it we don't get an error, instead we get `undefined`. This is because JavaScript hoists the declaration `var x` to the top of its scope but not the initialization `x = 5`. It's as if the code were rewritten like this:
|
||||
|
||||
```js
|
||||
var x;
|
||||
|
||||
Reference in New Issue
Block a user