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

160
Vistas
Why use return for methods that do not need a return value?

When I read the source code, I found that the author will use return where there is no need to use return.

http-party/node-portfinder


exports.getPort = function (options, callback) {
    // code...
    return _async.eachSeries(exports._defaultHosts, function(host, next) {
        // code ...
        return next();
    }
}

What is the purpose or need of this usage?

about 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

next is likely a promise. Maybe in your code it is not used (no then / catch), but there might (and should) be some.

In case the promise was not returned then there is no way to catch errors or make sequentials asynchronous calls.

about 4 years ago · Santiago Trujillo 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