Lodash is a library that works on the top of underscore.js. It proves to be very handy when it is used with objects, arrays, dictionaries and strings.
The lodash.fill() method is used to fill a set of values into the array in a given range.
lodash.fill(array, value, startIndex, endIndex)
- Array: It is the original array that is to be filled with certain values.
- Value: Value to be filled in the array.
- startIndex: It is the index from where value is to be filled.
- endIndex: It is the index to which values are to be filled in the array.
- All index less then endIndex are included except endIndex.
- Changes are done in the original array.
Return Value: It return the array.
Example 2: When empty array is given.
Example 3: when endIndex is greater then the size of array.