Constructor
new Stack()
Start with an empty array and store the length of the "list".
Note that we to store the length separately because the "memory" doesn't have a length that can be read.
Methods
peek() → {*}
Retrieve the item at the top of the stack without removing it from the stack
Returns:
- Type
- *
pop() → {*}
Pop items off of the end of our list.
Similar to push all we need to do is remove the value at the address at
the end of our list. Then just decrement length.
Returns:
- Type
- *
push(value)
Add an item to the end of the list.
Adding a value after the end of our list. Just add the value and increment the length.
Parameters:
| Name | Type | Description |
|---|---|---|
value |
* | Value that should be added to the list |