Implement a stack using javascript
Problem description :
Create a stack data structure in javascript.
- Stack organizes data into the sequential order. It similar to the stack of books in a library or stack of dishes in the kitchen as shown below.
![tall-stack-of-books-min](/static/media/js-algo/tall-stack-of-books-min.png)
Logic :
- It is similar to linked list. Linked list has a head attribute whereas Stack has top attribute.
-
Linked list is usually visualized horizontally from (left to right ) whereas Stack is visualized vertically (from bottom to top).
-
Stack data structure supports two basic operations : push and pop as shown below.
![stack-min](/static/media/js-algo/stack-min-1.png)
- I would encourage reading Create singly linked list in javascript post before reading this solution.