fill es-toolkit
Fills array elements with a specified value. Modifies the original array directly.
toFilled returns a new array instead of modifying the original.
Usage
fill(arr, value, start?, end?)
Use fill when you want to fill a specific range of an array with a specified value. It replaces elements from the start position to just before the end position with the provided value. If you don't specify start or end positions, it fills the entire array.
You can also use negative indices. Negative indices count from the end of the array.
Parameters
The array to fill.
The value to fill the array with.
The start position. Default is 0.
The end position. Default is the array length.
Returns
Returns the original array filled with values.
Source: es-toolkit
Re-exported verbatim from es-toolkit. Implementation, edge cases, and performance behavior are owned upstream. This page mirrors the documentation at the pinned version; the linked source is authoritative.