본문으로 건너뛰기
Chloe
chloe
글로그인
OverviewPostsPlayground

© 2026 Hyunjoo. Built with Next.js

← Playground 목록

스택과 큐

LIFO 스택과 FIFO 큐의 push/pop, enqueue/dequeue 흐름을 비교해 확인합니다.

stackqueueLIFO/FIFO
비어있음
Stack (LIFO)
빈 스택

소스 코드

Stack · JavaScript
1class Stack {
2 constructor() {
3 this.items = [];
4 }
5 
6 push(value) {
7 this.items.push(value);
8 }
9 
10 pop() {
11 return this.items.pop();
12 }
13 
14 peek() {
15 return this.items.at(-1);
16 }
17}

Step

1 / 11