Answers for "await setTimeout"

1

await setTimeout

function timeout(ms) {
    return new Promise(resolve => setTimeout(resolve, ms));
}
async function sleep(fn, ...args) {
    await timeout(3000);
    return fn(...args);
}
Posted by: Guest on November-26-2020
3

await set timeout

await new Promise(resolve => setTimeout(resolve, 1000));
Posted by: Guest on March-26-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language