ReadonlyrevisionA number that changes on every change to the contents — adding, removing or replacing an element — and never on a read. Watch it to detect changes; its exact values are unspecified. Time: O(1).
ReadonlysizeThe number of elements. Time: O(1).
The value-equality protocol; delegates to equals. Time: as equals.
The value-equality protocol: a hash consistent with equals, computed with hash.
Time: as the implementation documents.
Returns an iterator over the elements in iteration order.
Time: O(1) to create; each step amortised O(1) unless the implementation documents otherwise.
A new iterator.
Returns whether other is equal to this collection, as the collection's family defines;
otherwise only the collection itself. Time: as the implementation documents.
Any value.
true when equal.
Calls action once per element in iteration order, with this set to thisArg.
Time: O(n) plus the calls.
Called with each element.
OptionalthisArg: unknown
The this value for action.
Returns whether some element is equal to element under the collection's equality
(SameValueZero unless the collection says otherwise). Time: as the implementation documents.
The value to look for.
true when an equal element is present.
Returns whether the collection has no elements.
Time: O(1).
size === 0.
Returns a live view of this collection in reverse order: changes to either show in the other.
Time: O(1).
The reversed view.
Returns a new array of the elements in iteration order; changing it does not change the collection.
Time: O(n).
A new array.
Returns a new array of the elements, so JSON.stringify writes the collection as an array.
Time: O(n).
A new array.
Returns the class name, size and elements, e.g. ArrayList(3) [1, 2, 'a'].
Time: O(length of the output) for flat contents; each level of nested arrays or collections copies its text once more.
The text.
The read-only view of a collection with a defined order and a first and last element.
Example