Last In First Out 이라는 개념을 가진 선형 자료구조다.
바닥이 막힌 상자라고 생각할 수 있다.
맨 위에 있는 요소부터 꺼내야 맨 아래에 있는 요소를 꺼낼 수 있다.
js에서 배열은 유연하기 때문에 구현에 더 유리하다.
const stack = [];
// push
stack.push(1);
stack.push(2);
stack.push(3);
console.log(stack);
// pop
stack.pop();
console.log(stack);
// Get Top
console.log(stack[stack.length - 1]);