stack.push(item); // Add one or more items to the top of the stack stack.pop(); // Removes and retiurns the item at the top of the stack (ie the newest thing) stack.peek; // Return what is at the top of the stack or undefined if empty stack.isEmpty/.isFull; stack.length; // How many items in stack stack.data; // Get the underlying array
Stack (mutable)
Example: Overview
Example
Stack can also be created from the basis of an existing array. First index of array will be the bottom of the stack.