Created
May 29, 2017 05:27
-
-
Save vaidehijoshi/8c07730153222f686d23f932716eb5d6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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