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

261
Vistas
Node Js what is the different between the coding

I have one question regarding Node js

Method 1:

app.post('/password-reset', resetPassword)

function resetPassword() {
// code here
}

vs

Method 2:

app.post('/password-reset',  function(req, res){
// code here
});

I understand that both are doing the same thing but why do we need method 1?

Is that any scenario that I must use method 1?

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

0

The only practical difference is that method 1 leaves a resetPassword function in the scope of the module which can be reused later. That isn't likely to be useful for the endpoint function of a route which is likely to be assigned exactly once. You might want to export that function and unit test it though.

Everything else is code style preference. People would probably disagree on which is easier to read / maintain. Pick a style that suits you and the people you work 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