## A stack is a linear data structure that observes LIFO
Think of a stack like a pile of books: the last book that you add is the nearest to the top and therefore the first one that you can remove.
If you want to get a book that is not at the top, you have to first remove the books that are above it to get to it.
This type of data structure is linear and only allows sequential, not random, access. It is an example of 'last one in first one out'.
## We can build a stack from an array
A stack is an example of a data structure that can be built by adapting an array. If you think about it, all that is needed is an array to store the data, an `array push` method to add elements to the 'end' or the 'bottom' of the stack and an `array pop` method to remove the element at the top.
## Demonstration
Below we create a stack constructor, using a class. An object created from this template will have the following properties and methods:
- Any application that wants to got 'back in time' must utilise a stack. For example, the 'undo' function in most software is a function of a stack. The most recent action is at the top, and under that is the second most recent and so on all the way back to the first action.
- Recursive functions: a function that calls itself repeatedly until a boundary condition is met is using a stack structure. As you drill down through the function calls you start from the most recent down to the last.
- Balancing parentheses. Say you want to check if the following string is balanced `[()]` . Every time you find an opening parentheses. You push that to the front of a stack. You then compare the closing parentheses with the order of the stack. The same could be done when seeking to find palindromes. This sort of thing could be a code challenge so build an example.