QuestenaՎարժանք, որը ցույց է տալիս՝ ինչ կրկնել հաջորդիվ
Հարց 113

What happens when reduce is called on an empty array without supplying an initial accumulator value?

  1. It throws a TypeErrorՃիշտ պատասխան
  2. It returns undefined
  3. It returns zero for every reducer
  4. It skips the call and returns the empty array

Բացատրություն

With no elements and no explicit initial value, reduce has nothing from which to establish its accumulator, so it throws a TypeError. Supplying an initial value would make that value the result for the empty array instead.

Շարունակեք այս թեստով

Սկսել վարժանքը
Հարց 113: What happens when reduce is called on an empty array… · JavaScript Fundamentals · Questena