JS Array Includes

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

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

The includes() method is case sensitive.

Syntax

array.includes(element, start)

Parameters

Parameter Description
element Required.
The value to search for.
start Optional.
Start position. Default is 0.

Return Value


Type Description
A boolean true if the value is found, otherwise false.
<!DOCTYPE html>
<html>
<head>
  <title>JavaScript</title>
  <script>
    var a = ["Sanjay", "Aman", "Rehman", "Rahul"];
    document.write(a + "<br><br>");

    var b = a.includes("Neha");
    document.write(b + "<br><br>");

    var c = a.includes("Aman");
    document.write(c + "<br><br>");

    var d = a.includes("aman");
    document.write(d + "<br><br>");
  </script>
</head>
<body>

</body>
</html>