async is a promise function and with setimeout how it works [duplicate]
问题 This question already has answers here : Combination of async function + await + setTimeout (10 answers) Is using async in setTimeout valid? (2 answers) Closed 17 days ago . const name = async () => { setTimeout(() => { return Promise.resolve("1") },1000); }; (async function () { console.log("hello2"); })(); const timer = async () => { console.log(await name()); console.log("hello4"); }; timer() expected output hello2 1 hello4 output is hello2 undefined hello4 If i removed the settimeout