FIFO behavior for Array.pop in javascript?
The method is array.shift()
. It pulls the first array element much as array.pop()
pulls the last element.
You can use array.prototype.shift()
>> array = [];
>> array.push(1);
>> array.push(2);
>> array.push(3);
>> array.shift(); //outputs 1 and removes it from the array
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/shift