# Stack

*noun*

say it: **“STAK”** **/stæk/**

A last-in, first-out collection: items are pushed on top and popped off the top.

## What is a **stack**?

A **stack** keeps items last in, first out, like a stack of plates: you **push** an item on top, **pop** the top item off, and **peek** at the top without taking it. All three are O(1). Undo buttons, a browser's back button, bracket matching and the call stack are all stacks.

## In a sentence

- “The editor keeps every change on a **stack**, so undo always reverses the newest one first.”

Level: Apprentice · [More Data Structures terms at this level](https://www.ask-codey.com/glossary?category=data-structures&level=2)

Updated: November 9, 2026

Source: https://www.ask-codey.com/glossary/stack
