This content originally appeared on DEV Community and was authored by Azaan Suhail
Day 5 of My JavaScript Visual Series 📚✨
💡 Hoisting in JavaScript – JavaScript ka jugaadu nature 😄
Real life example : -
Imagine you’re in class and the teacher asks a question…
You didn’t study, but your bestie already gave your name to answer — JavaScript does the same thing 😅
- It remembers your function or variable declarations even before they are actually written — that’s Hoisting.
🔁 Real-Life in Code:
🔹 Function Hoisting
You can call the function before declaring it.
greet();
function greet() {
console.log("Good to see you!");
}
🔹 Anonymous Function / Arrow Function?
No shortcut! These won’t work if you call them before defining.
sayHi(); // ❌ Error
var sayHi = function() {
console.log("Hey there!");
};
🔹 var?
Hoisted, but value is undefined
console.log(x); // undefined
var x = 10;
🔹 let & const? [Interview Question]
JavaScript: “I know it exists… but you can't touch it yet 😶”
They live in a Temporal Dead Zone (TDZ).
console.log(y); // ❌ ReferenceError
let y = 5;
🎯 Summary:
)> Except Arrow functions all normal function show the hoisting nature.
)> Var is hoisted , let & const are also hoisted only in the temporal deadzone.
This content originally appeared on DEV Community and was authored by Azaan Suhail

Azaan Suhail | Sciencx (2025-09-22T16:08:26+00:00) Day 5 of Complete JavaScript in 17 days | Visual Series📚✨. Retrieved from https://www.scien.cx/2025/09/22/day-5-of-complete-javascript-in-17-days-visual-series%f0%9f%93%9a%e2%9c%a8/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.