Array.prototype.fill

Changes all array elements from start to end index to the given value and returns the modified array.

Syntax

fill(value, start?, end?)

Parameters

Return value

The original modified array.

Examples

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" ]