Memory Model Visualizer
See How Memory Works
Interactive visualization of stack vs heap memory allocation. Understand what happens when you write code like let x = y or pass objects to functions.
Primitives vs References
See the fundamental difference between primitive values and object references.
beginnerprimitives
Normal
Pseudocode
1x = 52y = x3y = 1045obj1 = { value: 5 }6obj2 = obj17obj2.value = 10
Memory State
Stack
Heap
Reference
Stack Memory
Global Frame
No variables
Heap Memory
Heap is empty
Step 1 of 7
Program starts. Stack contains global frame, heap is empty.
Learning Objectives
- Primitives store values directly in stack
- Objects store data in heap with references in stack
- Copying primitives creates independent values
- Copying references creates aliases (both point to same object)
What You'll Learn
Stack vs Heap Memory
Understand where variables and objects are stored, and why it matters for your code.
Pass by Value vs Reference
See the difference between copying primitives and copying references to objects.
Object Aliasing
Learn why modifying one variable can affect another, and how to avoid aliasing bugs.
Function Call Mechanics
Watch stack frames being created and destroyed as functions are called.