Lab

How Hoisting Works

beginner
1/6

Step Explanation

Understand what is happening first

1/6

Execution Visualizer

Watch memory, stack, queues, and output

Execution Visualizer

live
Before running any code, JavaScript scans the entire file. It finds all var declarations and function declarations and puts them in memory — this is called hoisting.

Call Stack

1 frame
TOP ↑
main()
frame 0
↓ BOTTOM
Global Context

Memory

2 variables

Stack Memory

greetingvarnew
"undefined"

Heap Memory

sayHellofn→ refnew
"function"
Console Output

awaiting output...

varfnobjarrclosure

Code Preview

Active line 1

Code

line 1
JavaScript
Tap Expand to view full code

1/6