The type of elements in the stack.
Readonly
capacityThe maximum number of elements the collection can hold.
If the collection is unbounded, this will be Infinity
.
Removes all elements from the collection.
Concatenates the given items to the end of the collection and returns an iterator over the merged items.
This method does not mutate the original collection.
The items to merge.
An iterator of the merged items.
Returns the number of elements in the collection.
Removes and returns the item at the top of the stack.
The item at the top of the stack, or undefined
if the stack is empty.
Adds one or more items to the top of the stack.
The items are added in the order they are provided. The last item in the argument list will be the first one to be popped.
The items to add to the stack.
Removes all the items matching the given predicate from the collection.
An iterable of the removed items.
Replaces all the item matching the given predicate in the collection with a new item.
An iterable of the replaced items.
Replaces the first occurence of the item matching the given predicate in the collection with a new item.
true
if the item was found and replaced, false
otherwise.
Returns the item at the top of the stack without removing it.
The item at the top of the stack, or undefined
if the stack is empty.
Same as push
, but waits for capacity if the operation would exceed it.
Optional
signal: null | AbortSignalOptional abort signal to cancel the operation.
Interface representing a stack data type
A stack is a collection that follows the Last In First Out (LIFO) principle, where the last item added to the stack is the first one to be removed.