Skip to content
On this page

Stack<T>.length

Gets the number of elements contained in the Stack<T>.

Property Value

number

Example

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

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

stack.length // => 3

Remarks

Retrieving the value of this property is an O(1) operation.