Array.prototype.includes() method in JavaScript.

The JavaScript Array.protoype.includes() method is used to check if an array contains a given element or not.

Following is the code for the Array.protoype.includes() method −


 Live Demo

<!DOCTYPE html>
<html lang="en">
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
   body {
      font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
   .sample {
      font-size: 20px;
      font-weight: 500;
<h1>JavaScript Array includes()</h1>
<div class="sample"></div>
<button class="Btn">CLICK HERE</button>
<h3>Click on the above button to check if the array contains lion element or not</h3>
   let fillEle = document.querySelector(".sample");
   let arr = ["cow", "bull", "lion", "tiger", "sheep"];
   fillEle.innerHTML = arr;
   document.querySelector(".Btn").addEventListener("click", () => {
      fillEle.innerHTML = "Lion is present in array: " + arr.includes("lion");


The above code will produce the following output −

On clicking the “CLICK HERE” button −