The array to fill.
Optional
value: TThe value to fill array
with.
Returns array
.
5.10.0
var array = [1, 2, 3];
fill(array, 'a');
console.log(array);
// => ['a', 'a', 'a']
fill(Array(3), 2);
// => [2, 2, 2]
fill([4, 6, 8, 10], '*', 1, 3);
// => [4, '*', '*', 10]
Optional
value: anyOptional
start: numberOptional
end: number
Fills elements of
array
withvalue
fromstart
up to, but not including,end
.Note: This method mutates
array
.