JavaScript Array fill()
JavaScript Array fill()
The fill() method is used to fill specified elements in an array with a value. It will overwrite the original array. If starting and ending positions are not specified then all elements will be filled.
Syntax:-
Its syntax is- array.fill(value, start, end)
Return:-
Its return is:- A filled array.
Further Explanation:-
Parameter | Description |
value | Required. The value to fill in. |
start | Optional. The starting index position. Default is 0. |
end | Optional. The stopping index position. Default is array length. |