Follow The New Tutorial updates on WhatsApp, Telegram or YouTube.

JavaScript Array includes() method

The JavaScript array includes() method checks whether the given array contains the specified element.

The includes() method is case sensitive.

Blank spaces are also taken into account when searching a String or an Array.

JavaScript Array includes() method returns true if an array contains the element, otherwise false.


array.includes(element, start)

This method accepts two parameters as mentioned above and described below:

element – Required. The value to be searched.

start – Optional. Start position. Default is 0. It represents the index from where the method starts search.

Return Value

A boolean value.

The includes() method returns true if an array contains a specified value.

The includes() method returns false if the value is not found.


Below are the examples of the Array includes() method.

const array1 = [1, 2, 3];

// expected output: true

const pets = ['cat', 'dog', 'bat'];

// expected output: true

// expected output: false

[1, 2, 3].includes(2)         // true
[1, 2, 3].includes(4)         // false
[1, 2, 3].includes(3, 3)      // false
[1, 2, 3].includes(3, -1)     // true
[1, 2, NaN].includes(NaN)     // true
["1", "2", "3"].includes(3)   // false

const furniture = ['table', 'chair', 'cupboard', 'wardrobe', 'stool'];
// Expected output: true