skip to Main Content

javascript await – how does it know the resolve result

From the tutorial: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/await function resolveAfter2Seconds(x) { return new Promise((resolve) => { setTimeout(() => { resolve(x); }, 2000); }); } async function f1() { const x = await resolveAfter2Seconds(10); console.log(x); // 10 } f1(); I can see 10 going all…

VIEW QUESTION
Back To Top
Search