The type of elements in the list.
Optional
iterable: Iterable<T, any, any>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.
Returns the number of elements in the collection.
Returns the item at the specified index.
If the index is negative, it counts from the end of the list.
If the index is out of bounds, undefined
is returned.
The index of the item to retrieve.
The item at the specified index, or undefined
if the index is out of bounds.
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.
Sets the item at the specified index.
If the index is negative, it counts from the end of the list. If the index is equal to the length of the list, the item is appended to the end. If the index is out of bounds, a RangeError is thrown.
The index at which to set the item.
The item to set.
Slice the list to a new list from start to end.
This method does not mutate the original list.
The range is specified by the start
and end
parameters, which are
inclusive and exclusive, respectively. If start
is omitted, it defaults
to 0
. If end
is omitted, it defaults to the length of the list.
If either start
or end
is negative, they refer to positions from the end
of the list. For example, -1
refers to the last element, -2
refers to
the second last element, and so on.
If start
is greater than or equal to end
, the result is an empty iterator.
If the start
index is out of bounds, a RangeError is thrown. If end
is
out of bounds, it is clamped to the valid range.
Optional start index of the range (inclusive).
Optional
end: numberOptional end index of the range (exclusive).
An iterator for the elements in the specified range.
Change the content of the list by removing or replacing existing elements and/or adding new elements in place.
If the start index is negative, it counts from the end of the list. If the start index is equal to the length of the list, no elements are removed and the items are appended to the end of the list. If the start index is out of bounds, a RangeError is thrown.
If deleteCount is omitted, it defaults to Infinity
, meaning all elements
from the start index to the end of the list will be removed.
If deleteCount is greater than the number of elements from start to the end
of the list, it will remove all elements from start to the end of the list.
If deleteCount is 0
or negative, no elements will be removed.
If items are provided, they will be inserted starting at the start index.
The index at which to start changing the list.
The number of elements to remove from the list. Defaults to Infinity
The elements to add to the list, beginning at the start index.
An iterable of the removed items.
Same as set
, but waits for capacity if the operation would exceed it.
Optional
signal: null | AbortSignalOptional abort signal to cancel the operation.
A "head-tail" linked list implementation.
Time complexity: