Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

1 Answer
karthikeya Boyini

The includes() function of the TypedArray object accepts a value and verifies whether this typed array contains the specified element. If the array contains the given element it returns true else, it returns false.

Syntax

Its Syntax is as follows

typedArray.includes()

Example

Live Demo

<html>
   <head>
      <title>JavaScript Array every Method</title>
   </head>
   <body>
      <script type="text/javascript">
         var int32View = new Int32Array([21, 19, 65, 21, 14, 66, 87, 55 ]);
         document.write("Contents of the typed array: "+int32View);
         document.write("<br>");
         var contains = int32View.includes(66);
         if(contains) {
            document.write("Array contains the specified element");
         }else {
            document.write("Array doesn’t contains the specified element");
         }
      </script>
   </body>
</html>

Output

Contents of the typed array: 21,19,65,21,14,66,87,55
Array contains the specified element

Example

Live Demo

<html>
   <head>
      <title>JavaScript Array every Method</title>
   </head>
   <body>
      <script type="text/javascript">
         var int32View = new Int32Array([21, 19, 65, 21, 14, 66, 87, 55 ]);
         document.write("Contents of the typed array: "+int32View);
         document.write("<br>");
         var contains = int32View.includes(762);
         if(contains) {
            document.write("Array contains the specified element");
         }else {
            document.write("Array doesn’t contains the specified element");
         }
      </script>
   </body>
</html>

Output

Contents of the typed array: 21,19,65,21,14,66,87,55
Array doesn’t contains the specified element

Advertisements

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.