Includes Method Array tutorial in JavaScript

 <!DOCTYPE html>

<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Includes Method Array</title>
    <script>
        var a = ["Sanjay", "Aman", "Rehman", "Rahul"];
        document.write(a + "<br><br>");

        var b = a.includes("Rahul");
        document.write(b + "<br><br>");
        var c = a.includes("Neha");
        document.write(c + "<br><br>");
        if (a.includes("Sanjay")) {
            document.write("Sanjay is present in Array<br><br>");
        }
        else {
            document.write("Sanjay is not present in Array<br><br>");
        }
        if (a.includes("Neha")) {
            document.write("Neha is present in Array<br><br>");
        }
        else {
            document.write("Neha is not present in Array<br><br>");
        }
    </script>
</head>

<body>
</body>

</html>


Comments

Popular posts from this blog

Generators tutorial in Advance JavaScript

Document Object Module DOM querySelector and querySelectorAll tutorial in JavaScript

Find Even and Odd Numbers with Loops tutorial in JavaScript