fill
arrayFills elements of array with value from start up to, but not including, end.
Signature
fill<T>(array: any[], value: T, start?: number, end?: number): any[]Parameters
| Name | Type | Description |
|---|---|---|
array | any[] | The array to fill |
value | T | The value to fill array with |
start? | number | The start positionDefault: 0 |
end? | number | The end position |
Returns
any[] - Returns array
Examples
Fill entire array
import { fill } from 'dashlite'
const array = [1, 2, 3]
fill(array, 'a')
console.log(array)Output:
['a', 'a', 'a']Fill with range
import { fill } from 'dashlite'
const result = fill([4, 6, 8, 10], '*', 1, 3)
console.log(result)Output:
[4, '*', '*', 10]Available since version 1.0.0