Why not call the following then when the argument to Promise.resolve is thenable?

Promise.resolve()
.then( value => {
    console.log(0);
    return Promise.resolve({
        then() {
            console.log(1);
        }
    })
})
.then( value => {
    
    return Promise.resolve({
        then() {
           console.log(2);
        }
    })
})
.catch(()=>{
   console.log("not yet");
}) 
Apr.21,2022

MDN promise thenable
thenable is used in this way

Promise.resolve({
  then(resolve) {
    console.log(1);
    resolve(2)
  }
}).then(v=>{
  console.log(v) //2
})

thenable mainly ensures that all kinds of Promise/A+ implementations can be mixed.
is generally not used. Just remember this when using promise .

Menu