Stack size
getting current Stack size
const s = new Stack<number>();const currentSize = s.push(1).push(2).push(3).getSize();console.log(currentSize); // 3
Top element in the stack;
Returning the top element of the stack;
const s = new Stack<number>();const top = s.push(1).push(2).push(3).peak();console.log(top); // 3
Remove item from top of the Stack
self reference
Popping items from Stack
const s = new Stack<number>();s.push(1).push(2).push(3).pop(); // [$base, 1, 2]
Push new data to Stack
Pushing data to stack
const s = new Stack<number>();s.push(1).push(2).push(3) // [$base, 1, 2, 3]
the data you want to push to stack
Viewing the stack
const s = new Stack<number>();s.push(1).push(2).push(3).view();// Stack Top// 3// ----------// 2// ----------// 1// ==========// Stack Base
Generated using TypeDoc
Returns
Stack size
Example
getting current Stack size