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
<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
<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