Error AtlasError Documentation and Resolution

JavaScript reduce was called on an empty array without an initial value

TypeError: Reduce of empty array with no initial value

JavaScript could not reduce an empty array because no initial accumulator value was provided.

TypeError: Reduce of empty array with no initial valueruntime
TypeError: Reduce of empty array with no initial value
  • Array.prototype.reduce is called on an empty array without an initial accumulator.
  • Filtering or preprocessing unexpectedly produced an empty array.
  • Code assumes at least one element is always present.
  1. Pass an explicit initial value to reduce().
  2. Handle empty arrays before calling reduce().
  3. Check upstream filtering or data loading that may produce no items.
MDN: TypeError: Reduce of empty array with no initial value
JavaScript Reduce of empty array with no initial value | Error Atlas