Skip to main content

fill

_.fill(start, end, value, array) # Ⓢ [Ⓣ][1] Ⓝ

Fills elements of array with value from start up to, but not



including, end.




Since​

3.2.0

Arguments​

  1. start (number): The start position.
  2. end (number): The end position.
  3. value (*): The value to fill array with.
  4. array (Array): The array to fill.

Returns​

(Array): Returns array.

Example​

var array = [1, 2, 3];

_.fill(0, array.length, 'a', array);
// => ['a', 'a', 'a']

_.fill(0, Array(3).length, 2, Array(3));
// => [2, 2, 2]

_.fill(1, 3, '*', [4, 6, 8, 10]);
// => [4, '*', '*', 10]