
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Usage of fill() Method in JavaScript
The fill() method in JavaScript is used to fill elements with static value in an array. The following are the parameters for fill() −
- value− The value to be filled.
- begin− The start index to begin filling the array.
- end− The ending index to stop filling the array.
Example
You can try to run the following code to learn how to work with fill() method on JavaScript −
<!DOCTYPE html> <html> <body> <script> var num = ["One", "Two", "Three", "Four", "Five"]; document.write(num); document.write("<br>"+num.fill("Six",2,3)); </script> </body> </html>
Advertisements