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

180
Views
Can Javascript Promises be created with a single parameter?

When we create a Promise(), the constructor expects two parameters: resolve and reject.
Can I create a Promise using only resolve?

let promise = new Promise((resolve) => {});

I've tried and it works. But, it is a good practice? The promise is expected to be resolved in all circumstances.

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Yes, it's doable. If

  • you're sure the Promise will always resolve, or
  • there is no real way to detect if an error occurs (in which case a reject parameter wouldn't be used anyway)

then using only the resolve parameter is a reasonable possibility.

If there's any chance of an error - even an unexpected error - it'd be a good idea to use the reject parameter, though. Many errors are not expected, after all.

about 4 years ago · Juan Pablo Isaza Report

0

yes you can with

Promise.resolve(value);

refer https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/resolve

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!