Skip to content
On this page

Stack<T>.push

Inserts an object at the top of the Stack<T>.

Parameters

valueT: The object to push onto the Stack<T>.

Example

typescript
const stack = new Stack<number>();

stack.push(1);
stack.push(2);
stack.push(3);

stack.length // => 3

Remarks

This method is an O(1) operation.