![]() |
VOOZH | about |
Lodash _.fill() method is used to fill a set of values into the array in a given range.
_.fill(array, value, startIndex, endIndex);Note:
- All indexes less than endIndex are included except endIndex.
- Changes are done in the original array.
Example 1: In this example, we are replacing the first four elements of the given array by 10 by the use of the lodash _.fill() method.
Output:
Example 2: In this example, we are replacing the first ten elements of the given array by 10 by the use of the lodash _.fill() method. and endIndex is greater than the size of array.
Output: