The question is the title. I'm trying to get a deeper understanding of promises and I think I've figured out how Promise.resolve(thenable)
works, or at least mostly how it works, looking at the examples on MDN. I'm wondering if there's a difference between the two. I whipped up this example to show them behaving the same, in way that I would think would show differences in behaviour if there was going to be any. But obviously this test alone isn't good enough to conclude there's nothing different about them, so I've come here.
let thenable = {
then(resolve) {
setTimeout(()=>{
resolve((()=>{
console.log('test');
return thenable;
})());
}, 1000);
},
};
let p1 = Promise.resolve(thenable);
let p2 = new Promise(thenable.then);