LIFO 후입 선출
class Queue {
#array;
constructor(arr = []) {
if(!Array.isArray(arr)) {
throw new TypeError(`${arr} is not an array`);
}
this.#array = arr;
}
push(x) {
return this.#array.push(x);
}
pop() {
return this.#array.shift();
}
entries() {
return this.#array;
}
}
var queue = new Queue([1,2,3,4]);