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

227
Views
why callback in promise.then dont't return anything will make the state of promise returned by .then 'resolved'?

Here is a quote about Promise.then() from MDN.

Return value

Once a Promise is fulfilled or rejected, the respective handler function (onFulfilled or onRejected) will be called asynchronously (scheduled in the current thread loop). The behavior of the handler function follows a specific set of rules. If a handler function:

  • returns a value, the promise returned by then gets resolved with the returned value as its value.
  • doesn't return anything, the promise returned by then gets resolved with an undefined value.
  • throws an error, the promise returned by then gets rejected with the thrown error as its value.
  • returns an already fulfilled promise, the promise returned by then gets fulfilled with that promise's value as its value.
  • returns an already rejected promise, the promise returned by then gets rejected with that promise's value as its value.
  • returns another pending promise object, the resolution/rejection of the promise returned by then will be subsequent to the resolution/rejection of the promise returned by the handler. Also, the resolved value of the promise returned by then will be the same as the resolved value of the promise returned by the handler.

My question is why the state of promise returned by .then is resolved rather than fulfilled in second point?

It seems only have one state fulfilled. Why not use the word fulfilled like the fourth point?

In first point and second point, both states of promise return by .then is 'resolved'.

About first point, in most cases, the state is fulfilled . And if the callback return a thenable, the state of promise may be 'rejected':

let thenableObj = {
    then(thenableRes, thenableRej) {
        thenableRej('thenable reject')
    }
}   

let p = Promise.resolve('foo')

p.then(() => {
    return thenableObj
}) // Promise{<rejecter>: 'thenable reject'}

So, I can accept the word resolved. But, in the second point, I can't find any example to prove the word resolved is more precise than fulfilled.

More specifically, can you give some examples to prove:

  1. the state of the promise returned by .then will be rejected when the callback in .then don't return anything.
  2. the state of promise returned by .then will be "locked in" to match the state of another promise when the callback in .then don't return anything.

if neither works, why don't we use the word fulfilled like fourth point than resolved

about 4 years ago · Juan Pablo Isaza
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!