Skip to content

Commit 23f4db4

Browse files
feat: update hoisting
1 parent 5377400 commit 23f4db4

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

part1 (Basics)/08_hoisting.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
1-
// hoisting.js
2-
3-
// INFO: Hoisting in JavaScript
4-
51
/*
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.
84
95
Important:
106
- Only **declarations** are hoisted, not **initializations**.
@@ -16,7 +12,7 @@ Important:
1612
// Function call before it's defined – this works because function declarations are hoisted
1713
getName(); // Output: "JavaScript"
1814

19-
// Accessing a 'var' variable before declaration – it's hoisted with undefined
15+
// Accessing a 'var' variable before declaration – it's initialized with undefined
2016
console.log(x); // Output: undefined
2117

2218
// Accessing the function by name – shows the function definition

0 commit comments

Comments
 (0)