stack.push(item); // Return a new stack with item(s) added stack.pop(); // Return a new stack with top-most item removed (ie. newest) stack.peek; // Return what is at the top of the stack or undefined if empty stack.isEmpty; stack.isFull; stack.length; // How many items in stack stack.data; // Get the underlying array
Stack (immutable)
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. Stack