What does this log when you await an object that has a then method?
const thenable = {
then(resolve) {
console.log("then called");
resolve(42);
},
};
async function main() {
console.log("before await");
const value = await thenable;
console.log("value:", value);
const p = Promise.resolve(thenable);
console.log(p === thenable, Promise.resolve(p) === p);
}
main();
console.log("end");
The answer
Work out every line it logs, in order. Then check.
Checking your sign-in…