yuuka_maniaの日記: 続続 promise とか、 async とか、よくわからない
日記 by
yuuka_mania
色々書いてはいるものの、まだ、しっくりこない。以下は、3秒待ってから、 x と出力するサンプル。要は、 sleep(3) してからの printf 。 resolve を忘れずに。
(async ()=>{
await new Promise((resolve, reject) => {
setTimeout(() => {
console.log("waiting");
resolve();
}, 3000);
});
console.log("x");
})();
続続 promise とか、 async とか、よくわからない More ログイン