Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

158
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!