JS menunggu detik
//A
setTimeout( () =>{
//C - 1 second later
}, 1000);
//B
Puppy Cat
//A
setTimeout( () =>{
//C - 1 second later
}, 1000);
//B
setTimeout(function(){
console.log("Ready")
}, 1000);
//code before the pause
setTimeout(function(){
//do what you need here
}, 2000);
function sleep(milliseconds) {
const start = Date.now();
while (Date.now() - start < milliseconds);
}
console.log("Hello");
sleep(2000);
console.log("World!");
setTimeout(function () {
// ...
}, 10000);
// or
.then(() => {
// ...
({ timeout: 10000 });
});
wait(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}