//A
setTimeout( () =>{
//C - 1 second later
}, 1000);
//B
setTimeout(function(){
console.log("Ready")
}, 1000);
setTimeout(() => {console.log('1 second finished!')}, 1000);
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
async function demo() {
console.log('Taking a break for 2 seconds...');
await sleep(2000);
console.log('2 seconds later');
}
demo();
setTimeout(function () {
// ...
}, 10000);
// or
.then(() => {
// ...
({ timeout: 10000 });
});
setTimeout(function(){
2 console.log("Ready")
3}, 1000);