has(value)

Whether an equivalent value exists in this collection.

This operation is very fast for sets because they are backed by a hash table. The operation is fast for SortedSet and SortedArraySet by virtue of a binary search.

To avoid confusion with the linear search available as has(value, equals) on Array, List, and Deque, if you pass a second argument, this method will throw an exception.

On collections

Usage

  • has(value)

Example

var set = new Set([1, 2, 3]);
set.has(2);
set.has(4);

Related

  • has(key)

    Returns whether an entry with the given key exists in a Map.

  • has(value, equals?)

    Returns whether an equivalent value exists in this collection.