fix(curriculum) : Typo in "The var Keyword and Hoisting" (#63357)

This commit is contained in:
VINAY KUMAR
2025-10-31 15:01:59 +05:30
committed by GitHub
parent bc658f44be
commit 22beb5997f

View File

@@ -16,7 +16,7 @@ Let's start with variables hoisting, when you declare a variable using the `var`
```js
console.log(x); // undefined
var x = 5;
console.log(5); // 5
console.log(x); // 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 initialization `x = 5`. It's as if the code were rewritten like this:
@@ -40,7 +40,7 @@ function sayHello(){
In this case, we can call `sayHello()` before its declaration because the entire function is hoisted to the top of its scope.
It's important to note that hoisting works differently with `let` and `const` declarations introduced in ES6.
It's important to note that hoisting works differently with `let` and `const` declarations introduced in ES6.
```js
console.log(y); // Throws a ReferenceError