JavaScript ES6 – Array includes method

The JavaScript includes() method determines whether an array includes a certain value. If array contains the value, it returns true and if doesn’t have, it will return false.

Think of JavaScript array includes() method as: “I want to know if the array contains a value? yes/no answer!”

array includes() parameters

JavaScript array includes() method consists of following parameters:

  • searchElement – The value to search for within the array

How to check if an array contains a value in JavaScript? To find if a value exists in array in JavaScript we use array.includes() method.

const arr = [22, 8, 34];
const result = arr.includes(8);


// true

array includes() usage and tips

  • Use includes() method to check if value exist within an array
  • If value exist within array, it will return true
  • If value doesn’t exist, it will return false
%d bloggers like this: