Answers for "how to settimeout in javascript function with callback"

223

javascript settimeout

setTimeout(function(){
 	alert("Sup!"); 
}, 2000);//wait 2 seconds
Posted by: Guest on June-27-2019
0

set timeout javascript

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 December-08-2021

Code answers related to "how to settimeout in javascript function with callback"

Code answers related to "Javascript"

Browse Popular Code Answers by Language