Lodash reduce Supported Accumulator Types

The _.reduce function in the Lodash JavaScript library is a versatile aggregation utility that supports any valid JavaScript data type as an accumulator. Because JavaScript is dynamically typed, _.reduce does not restrict the accumulator to a predefined set of structures; developers can use primitive types such as numbers, strings, and booleans, complex references like plain objects and arrays, modern collections like Map and Set, or even omit the accumulator entirely to rely on the first element of the collection.

Primitive Types

Object and Array Types

ES6 Collections

Custom and Advanced Types

Omitted Accumulator (Default Behavior)

If the accumulator argument is omitted or passed as undefined, Lodash uses the first element of the collection as the initial accumulator value, and iteration begins with the second element. This behavior is standard for mathematical reductions like finding the maximum value (Math.max) or cumulative string joins where a separate seed value is unnecessary.