What does Array.prototype.reduce() return when called on an empty array without an initial value?

JavaScript Developer Medium

JavaScript Developer — Medium

What does Array.prototype.reduce() return when called on an empty array without an initial value?

Key points

  • Calling reduce() on an empty array without an initial value throws a TypeError
  • An initial value is needed to start the reduction process
  • This behavior is designed to avoid potential errors or unexpected outcomes

Ready to go further?

Related questions