Favorites

JavaScript Array.prototype.includes() Method

☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee
Array.prototype.includes()
JavaScript Array Instance methodThis method is supported by all modern browsers.
Updated 28th November 2026

The includes() method checks whether an array contains a certain value, returning true or false.

Description

The includes() method determines whether an array contains a value, returning true or false. It compares using SameValueZero, which is like === except that NaN is found too (indexOf() can't find NaN).

Objects are only found if it's the same object, not one with the same contents; use some() or find() to match by property. For repeated lookups in a large collection, a Set is faster.

A second argument sets where to start searching, and negative values count from the end, so arr.includes(x, -3) only checks the last three elements. Empty slots in sparse arrays are treated as undefined, so [ , 1].includes(undefined) is true. Strings have their own includes() method for finding text within a string.

Syntax

array.includes(searchElement)
array.includes(searchElement, fromIndex)

Parameters

  • searchElementThe value to look for.
  • fromIndexOptional. The index to start searching from. Negative values count from the end.

Return Value

true if the value is found, otherwise false.

Example

const pets = ['cat', 'dog', 'bat'];
console.log(pets.includes('cat'));
console.log(pets.includes('at'));
console.log([1, 2, NaN].includes(NaN));
console.log([{ id: 1 }].includes({ id: 1 }));   // different object

Browser Support

The following information will show you the current browser support for the Array.prototype.includes() method. Hover over a browser icon to see the version that first introduced support for this method.

This method is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported
☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee