Courses / JavaScript
23. Array.prototype.fill()
Fills all the elements of an array from a start index to an end index with a static value.
1 min read Chapter 23 of 99
JavaScript
Array.prototype.fill()
Array.prototype.fill() allows you to fill an array with a specific value.
"I want to quickly set all my array values to the same thing without a loop."
Array.prototype.fill() modifies all elements in an array from a start index to an end index with a specified static value. It's a quick way to initialize or reset array contents.
"I want to quickly set all my array values to the same thing without a loop."
Array.prototype.fill() modifies all elements in an array from a start index to an end index with a specified static value. It's a quick way to initialize or reset array contents.