Determines whether an iterable includes a certain element, returning true or false as appropriate. Strict equality (===) is used to compare elements.
===
Time complexity: O(n)
Space complexity: O(1)
The iterable to take elements from
The element to search for
true if any element is truthy, false otherwise
true
false
Iterable
includes([1, 2, 3], 2); // true Copy
includes([1, 2, 3], 2); // true
includes([1, 2, 3], 4); // false Copy
includes([1, 2, 3], 4); // false
Determines whether an iterable includes a certain element, returning true or false as appropriate. Strict equality (
===
) is used to compare elements.Time complexity: O(n)
Space complexity: O(1)