Skip to content

Instantly share code, notes, and snippets.

@vaidehijoshi
Created May 29, 2017 05:27
Show Gist options
  • Save vaidehijoshi/8c07730153222f686d23f932716eb5d6 to your computer and use it in GitHub Desktop.
Save vaidehijoshi/8c07730153222f686d23f932716eb5d6 to your computer and use it in GitHub Desktop.
// Create an empty queue.
var queue = [];
// Add values to the end of the queue.
queue.push(1); // queue is now [1]
queue.push(2); // queue is now [1, 2]
// Remove the value at the top of the queue.
var topOfQueueValue = queue.shift();
console.log(topOfQueueValue) // returns 1
// The queue now has just one element in it.
console.log(queue) // returns [2]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment