Skip to content

Latest commit

 

History

History
49 lines (39 loc) · 1.97 KB

fill.md

File metadata and controls

49 lines (39 loc) · 1.97 KB

Object Agent

A javascript library for working with objects

npm build coverage deps size vulnerabilities license


fill(length, [callback]) ⇒ Array.<unknown>

Returns an array of specified length filled with either the index value or the value returned from the provided callback.

Param Type Description
length number The desired length of the returned array.
[callback] function Provides one argument, the index of the returned array.

Example

import { fill } from 'object-agent';

fill(5);
// => [0, 1, 2, 3, 4]

fill(3, (index) => index * 3);
// => [0, 3, 6]