TypedArray ऑब्जेक्ट का includes() फंक्शन एक मान स्वीकार करता है और सत्यापित करता है कि यह टाइप्ड एरे निर्दिष्ट एलिमेंट को समाहित करता है या नहीं। यदि सरणी में दिया गया एलिमेंट है तो यह true लौटाता है अन्यथा false।
सिंटैक्स
इसका सिंटैक्स निम्नानुसार है:
typedArray.includes(searchElement[, fromIndex])
उदाहरण
<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 contain the specified element"); } </script> </body> </html>
आउटपुट
Contents of the typed array: 21,19,65,21,14,66,87,55 Array contains the specified element
उदाहरण
<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 contain the specified element"); } </script> </body> </html>
आउटपुट
Contents of the typed array: 21,19,65,21,14,66,87,55 Array doesn’t contain the specified element