Stack Data Structures, FILO/LIFO

Chris Haylett
2 min readOct 19, 2020

Stack databases are pretty useful and follow a couple rules on how things are applied added and removed to elements, following the First In Last Out or Last In First Out. These rules can be seen when we have a scenario where we may push something onto the end but that would also be the first item to be popped off our data structure.

We have access to native methods in JavaScript that provide a stack data structure through our array type objects and has rules set up for you with push, pop, unshift, shift. these can be rather useful as your trying to manipulate your data.

Some methods we don’t have available directly so for our Data Structure we may need to add our push, pop methods back to our Stack, this gives us the opportunity to decide what methods we’ll find useful in our implementation. Its best to have some base rules like pop and push set up but also its recommended a function that will return the top element or the length/size or a function to check whether the data structure is empty.

The usefulness of stacks really comes out when working towards speeding up our programs as we can design our data structure methods to work directly in constant time, our program will end up taking less memory. This can be great if your trying to avoid linear loops and power up your program.

Stacks are such a useful data base that should be implemented if your programs are crashing from memory issues. Or simply if you enjoy using them they are a great tool in your giant coding tool-belt.

Sources:

--

--

Chris Haylett

Libra 🌞 Cap 🌖 Leo 🌠 /// aspiring dev /// /// She / They ///