Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

184
Vistas
Confusing on Reduce and Arrow function

I am now looking at the following post Javascript Algorithm Attempting to Implement Call Back Function. I can understand the other parts but particularly confuse at the following code. const sum = integerSet.reduce((total, item) => total + Math.pow(item, pow), 0);.
So, what is the purpose of adding 0 at the end and if we change from arrow function to normal function would it be change to this?
sum = integerSet.reduce(function(total, item) { return total + Math.pow(item,power),0; })
I have searched up the several reduce methods usage but still can't get the clear figure of how he use there so I decided to ask it here.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

The 0 gives you the starting point. From there everything will be calculated "on top" of this accumulator. So in your example the 0 would be the item to start with.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda