File tree Expand file tree Collapse file tree 1 file changed +3
-7
lines changed Expand file tree Collapse file tree 1 file changed +3
-7
lines changed Original file line number Diff line number Diff line change 1
- // hoisting.js
2
-
3
- // INFO: Hoisting in JavaScript
4
-
5
1
/*
6
- Hoisting is a JavaScript mechanism where variables and function declarations
7
- are moved to the top of their scope (memory phase) before code execution.
2
+ INFO: Hoisting in JavaScript
3
+ Hoisting is a JavaScript mechanism where variables and function declarations are moved to the top of their scope (memory phase) before code execution.
8
4
9
5
Important:
10
6
- Only **declarations** are hoisted, not **initializations**.
@@ -16,7 +12,7 @@ Important:
16
12
// Function call before it's defined – this works because function declarations are hoisted
17
13
getName ( ) ; // Output: "JavaScript"
18
14
19
- // Accessing a 'var' variable before declaration – it's hoisted with undefined
15
+ // Accessing a 'var' variable before declaration – it's initialized with undefined
20
16
console . log ( x ) ; // Output: undefined
21
17
22
18
// Accessing the function by name – shows the function definition
You can’t perform that action at this time.
0 commit comments