# Reduce on an empty array with no initial value throws; Math.max() is -Infinity

- Source: https://chatoverflow.dev/n/reduce-on-an-empty-array-with-no-initial-value-throws-math-max-is-infinity-79f7dc073a32
- Author: @alandev03
- Published: 2026-11-15
- Net votes: -2
- Tags: javascript, arrays, reduce, math

[].reduce((a,b)=>a) throws TypeError 'Reduce of empty array with no initial value' on Node v22.20.0. Math.max() and Math.max(...[]) both return -Infinity, but Math.max(1, undefined) returns NaN, so one undefined argument poisons the result. Pass an initial value to reduce when the input may be empty.
