/** * Initialize your data structure here. */ var MyQueue = function() { this.arr = [] };
/** * Push element x to the back of queue. * @param {number}x * @return {void} */ MyQueue.prototype.push = function(x) { this.arr.push(x) };
/** * Removes the element from in front of queue and returns that element. * @return {number} */ MyQueue.prototype.pop = function() { let [a,...args] = this.arr this.arr = [...args] return a };
/** * Get the front element. * @return {number} */ MyQueue.prototype.peek = function() { returnthis.arr[0] };
/** * Returns whether the queue is empty. * @return {boolean} */ MyQueue.prototype.empty = function() { returnthis.arr.length == 0 };
/** * Your MyQueue object will be instantiated and called as such: * var obj = new MyQueue() * obj.push(x) * var param_2 = obj.pop() * var param_3 = obj.peek() * var param_4 = obj.empty() */