Implement Queue using Stacks LeetCode solution in JavaScript
1var MyQueue = function () {2this.queue = [];3};45/**6* @param {number} x7* @return {void}8*/9MyQueue.prototype.push = function (x) {10this.queue.push(x);11};1213/**14* @return {number}15*/16MyQueue.prototype.pop = function () {17return this.queue.splice(0, 1);18};1920/**21* @return {number}22*/23MyQueue.prototype.peek = function () {24return this.queue[0];25};2627/**28* @return {boolean}29*/30MyQueue.prototype.empty = function () {31return this.queue.length === 0;32};3334/**35* Your MyQueue object will be instantiated and called as such:36* var obj = new MyQueue()37* obj.push(x)38* var param_2 = obj.pop()39* var param_3 = obj.peek()40* var param_4 = obj.empty()41*/