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

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

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 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!