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-
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
95Important:
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
1713getName ( ) ; // 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
2016console . log ( x ) ; // Output: undefined
2117
2218// Accessing the function by name – shows the function definition
You can’t perform that action at this time.
0 commit comments