LIFO 선입 선출
class Stack {
#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.pop();
}
entries() {
return this.#array;
}
}
var stack = new Stack([1,2,3,4]);