

| ADT | 설명 |
|---|---|
| push | stack에 새 요소 추가 |
| pop | stack의 맨 위에 있는 요소 삭제 |
| peek | stack의 맨 위에 있는 요소 확인 |
class Stack {
constructor() {
this._arr = [];
}
push(item) {
this._arr.push(item);
}
pop() {
return this._arr.pop();
}
peek() {
return this._arr[this._arr.length - 1];
}
}
const stack = new Stack();
stack.push(1);
stack.push(2);
stack.push(3);
stack.pop(); // 3
stack.peek(); // 2