TypedArray ऑब्जेक्ट का fill() फंक्शन सरणी के सभी आवश्यक/वांछित एलिमेंट्स को निर्दिष्ट मान (फिक्स्ड) से रिप्लेस करता है। यह फंक्शन तीन नंबर स्वीकार करता है: एक फिक्स्ड मान को दर्शाता है और अन्य दो प्रतिस्थापित किए जाने वाले एलिमेंट्स के भाग के प्रारंभ और अंत इंडेक्स को दर्शाते हैं (अंत मान वैकल्पिक है)।
सिंटैक्स
इसका सिंटैक्स निम्नानुसार है:
typedArray.fill(value[, start[, end]])
उदाहरण
<html> <head> <title>JavaScript Array every Method</title> </head> <body> <script type="text/javascript"> var int32View = new Int32Array([64, 89, 65,21, 14, 66, 87, 55]); document.write("Contents of the typed array: "+int32View); document.write("<br>"); result = int32View.fill(464, 3); document.write("Contents of the typed array after fill: "+int32View); </script> </body> </html>
आउटपुट
Contents of the typed array: 64,89,65,21,14,66,87,55 Contents of the typed array after fill: 64,89,65,464,464,464,464,464