DSA-VerseLearn by watching code run
DashboardData StructuresAlgorithmsVisualizerCORECoding PlaygroundInterview QuestionsComplexity AnalyzerLearning NotesBookmarksLearning ProgressSettings
Instrumented JavaScript implementation · lines sync with the animation

Run to execute this JavaScript code for real (output appears here).

Stack Push and Pop

stacks
push 10push 20push 30push 40pop()pop()pop()pop()
push
10
0
1
2
top = −1 (empty)

Size 0 / 3 · LIFO — the last value pushed is the first one popped

Top elementJust pushedPopped / rejected

Ready.

A stack is Last-In-First-Out (LIFO): push adds to the top, pop removes from the top. A fixed capacity shows overflow (push when full) and underflow (pop when empty). Press Run (Ctrl + Enter) to animate, or Step forward (F10) to go one event at a time.

1 / 24

Execution

Step

1 / 24

Line (JavaScript)

—

FUNCTION_CALLoperation 1

Variables

items[]
items.length0
capacity3
topnull
value10
Call stackdepth 1
push(10)← running

Operation counters

No counted operations yet.

Memory (measurable)

Stack size0 / 3
Per-operation extra spaceO(1)

Data structure state

bottom [] top