JS czeka na kilka sekund
//A
setTimeout( () =>{
//C - 1 second later
}, 1000);
//B
Puppy Cat
//A
setTimeout( () =>{
//C - 1 second later
}, 1000);
//B
setTimeout(function () {
// ...
}, 10000);
// or
.then(() => {
// ...
({ timeout: 10000 });
});
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();