Array.fill

Array.fill

Array.fill

Function

Fills a range of the array with the specified value.

Syntax

Parameters

ParametersTypeRequiredDefault valueDescription
valueAnyNoEmptyThe value to write.
startIntNo0Starting subscript; a negative number means counting backwards from the tail.
endIntNoArray lengthEnd subscript, excluding this position; a negative number means backward calculation from the tail.

Return value

TypeDescription
ArrayReturns the original array object.

Example

Notes

  • This method will modify the original array.