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 members. Time: O(1) on a set; O(k + log n) on a range view holding k of the set's n members, which counts the members in range.
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 members in this set's order.
Time: O(log n) to create; O(1) amortised per step.
A new iterator.
Returns the comparator that orders the set, or undefined for natural order; a reversed view
returns a function that orders in reverse.
Time: O(1).
The comparator, or undefined.
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(member, member, set) for each member in order, with this set to thisArg.
Time: O(n) plus the calls.
Called with each member twice and the set.
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 a live view of the members before to (exclusive by default).
Time: O(log n).
The high end, in this set's order.
Optionaloptions: BoundOptions | null
The inclusive flag.
The view.
Returns whether there are no members.
Time: O(1) on a set; O(log n) on a range view, which looks for one member in range.
size === 0.
Returns an iterator over the members, as values() does.
Time: O(log n) to create; O(1) amortised per step.
A new iterator.
Returns a live view of this set in the opposite order.
Time: O(1).
The reversed view.
Returns a live view of the members from from (inclusive by default) to to (exclusive by
default).
Time: O(log n).
The low end, in this set's order.
The high end, in this set's order.
Optionaloptions: SubSetOptions | null
The inclusive flags.
The view.
Returns a live view of the members from from on (inclusive by default).
Time: O(log n).
The low end, in this set's order.
Optionaloptions: BoundOptions | null
The inclusive flag.
The 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.
Returns an iterator over the members in this set's order.
Time: O(log n) to create; O(1) amortised per step.
A new iterator.
The read-only view of a sorted set: a set whose members are kept in the order of its comparator, with the ends, nearest-match queries and live range views. Two members are the same member when the comparator returns
0for them."Before" and "after" follow the set's own order, which is descending on a reversed view.
Example