Changes all array elements from start to end index to the given value and returns the modified array.
fill(value, start?, end?)
value
A value with which to fill the array.
start optional
An index at which to start filling. If negative, it is treated as length + start where length is the length of the array.
end optional
An index before which to stop filling. If negative, it is treated as length + end.
The original modified array.
Array(4).fill("Na")
[ "Na", "Na", "Na", "Na" ]
[1, 2, 3, 4, 5].fill(0, 1, 4)
[ 1, 0, 0, 0, 5 ]
["A", "B", "C"].fill("X", -2)
[ "A", "X", "X" ]