FILO(First In Last Out)형태의 자료구조
Stack은 먼저 들어 온 데이터가 나중에 나가는 형태(선입후출)의 자료구조이다.
입구와 출구가 동일한 형태로 다음과 같이 Stack을 시각화 할 수 있다.

Stack을 코드로 구현하기 위해서 push, pop 메서드를 사용한다.
push,pop메서드는 각각 배열 마지막요소의 데이터를 추가 및 삭제
const stack = [];
stack.push(5);
stack.push(2);
stack.push(3);
stack.push(7);
stack.pop();
stack.push(1);
stack.push(4);
stack.pop();
console.log(stack.join(' '));
// 실행 결과
5 2 3 1
FIFO(First In First Out)형태의 자료구조
Queue는 먼저 들어 온 데이터가 먼저 나가는 형태(선입선출)의 자료구조이다.
입구와 출구가 모두 뚫려 있는 터널과 같은 형태로 시각화 할 수 있다.

Queue를 코드로 구현하기 위해서 push, shift 메서드를 사용한다.
shift메서드는 첫번째 배열 요소를 삭제
const queue = [];
queue.push(5);
queue.push(2);
queue.push(3);
queue.push(7);
queue.shift();
queue.push(1);
queue.push(4);
queue.shift();
console.log(queue.join(' '))
// 실행결과
3 7 1 4