Home >>JavaScript Array Reference >JavaScript Array includes() Method

JavaScript Array includes() Method

JavaScript Array includes() Method

The JavaScript array includes()  method is an inbuilt function in JavaScript which is used to check whether the given array contains the specified element, it returns true or false as appropriate. It returns true if the element is present in an array, otherwise false.

Syntax:
array.includes(searchElement)

Parameter Values

Parameter Description
element It is required. The element which is searched
start It is optional. It represents the element at which position in the array to start the search. Default is 0.

Browser Support

Method Chrome Edge Firefox Safari Opera
includes() 47 14.0 43 9 34
Here is an example of Array Includes() method:
<html>
<body>
<p id="arrinc"></p>
<script>
var color = ["Red", "Blue", "Green", "Yellow"];
var x = color.includes("Yellow");
document.getElementById("arrinc").innerHTML = x;
</script>
</body>
</html>
Output:

Example 2:
<html>
<body>
<script>
var inc1=["HTML","CSS","BOOTSTRAP"]
var res=inc1.includes("AngularJS",1);
document.writeln(res);
</script>
</body>
</html>
Output:

No Sidebar ads