지니씨·2021년 8월 10일
0

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]);
profile
하루 모아 평생 🧚🏻

0개의 댓글