Computer >> कंप्यूटर ट्यूटोरियल >  >> प्रोग्रामिंग >> JavaScript

JavaScript में TypedArray.includes() फंक्शन


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

  1. जावास्क्रिप्ट Array fill() फंक्शन जावास्क्रिप्ट Array fill() फंक्शन

    जावास्क्रिप्ट का fill() मेथड एरे में एलिमेंट्स को एक स्टैटिक वैल्यू से भरने के लिए उपयोग किया जाता है। सिंटैक्स इस प्रकार है: array.fill(value, start, end) ऊपर, value एरे में भरने का मान है, start एरे भरना शुरू करने का इंडेक्स है, जबकि end एरे भरना बंद करने का इंडेक्स है। उदाहरण 1 <!DOCTYPE ht

  1. जावास्क्रिप्ट Array.of() फंक्शन जावास्क्रिप्ट Array.of() फंक्शन

    जावास्क्रिप्ट का Array.of() मेथड पैरामीटर वैल्यूज के रूप में वेरिएबल्स के साथ एक नया एरे इंस्टेंस बनाने के लिए उपयोग किया जाता है। सिंटैक्स इस प्रकार है: Array.of(element0, element1, ..., elementN) ऊपर, एलिमेंट्स पैरामीटर वैल्यूज के रूप में वैल्यूज हैं। उदाहरण 1 <!DOCTYPE html> <html>

  1. जावास्क्रिप्ट array.includes() फंक्शन जावास्क्रिप्ट array.includes() फंक्शन

    जावास्क्रिप्ट का array.includes() मेथड चेक करने के लिए उपयोग किया जाता है कि क्या एरे में एक निर्दिष्ट एलिमेंट है। सिंटैक्स इस प्रकार है: array.includes(element, fromIndex) ऊपर, पैरामीटर element खोजने के लिए एलिमेंट है। fromIndex पैरामीटर वह पोजीशन है जहां से खोज शुरू करनी है। उदाहरण 1 <!DOCTY