class Queue {
constructor() {
this.array = [];
}
peek() {
return this.array[this.array.length - 1];
}
push(value) {
this.array.unshift(value);
}
pop() {
return this.array.pop();
}
empty() {
return !this.array.length;
}
}
const queue = new Queue();
queue.push(1);
queue.push(2);
console.log(queue);
console.log(queue.peek());
console.log(queue.pop());
console.log(queue.empty());