The First In, First Out (FIFO) Programming Logic

By: Dusty Arlia
Published on September 19, 2012
Last Updated on Thursday, July 16, 2015 at 7:14 PM
Total Updates: 4

When you are programming you might come across this concept of First In, First Out or FIFO for short. This concept deals with managing items in an array. When you follow the First in, First Out programming logic, the first item in your array is taken out of the array and saved in a variable. Here's how that would look like if you're programming in JavaScript:

newLocationForFirstItem = myArray.shift();

To add an item to the end of the array, your code would look like this:

myArray.push('New string gets added to the end');

You can think of this programming logic like you think of a line for a roller coaster. The first in line gets to go on the ride first, hence the name First In, First Out.