The type of elements in the list.
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.
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.
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.
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: numberOptional 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.
Optional
deleteCount: numberThe 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.
The same as splice
, but waits for capacity if the operation would exceed it.
Optional
deleteCount: numberOptional
items: Iterable<T, any, any>Optional
signal: null | AbortSignalOptional abort signal to cancel the operation.
Interface representing an ordered data collection.
The list does not allow
undefined
as a valid element.The list may or may not be optimized for random access, depending on the implementation.
Contrary to Javascript Array, the list cannot be sparse (i.e., it cannot have "holes" or missing elements). All indices between
0
andcount() - 1
are guaranteed to be valid.The list may have a fixed capacity, in which case it cannot grow beyond that capacity. If the list is unbounded, its capacity is
Infinity
.