tunggu javascript waktu
//code before the pause
setTimeout(function(){
//do what you need here
}, 2000);
PutterBeanut
//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!");
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
wait(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
function wait(milliseconds) {
const date = Date.now();
let currentDate = null;
do {
currentDate = Date.now();
} while (currentDate - date < milliseconds);
}
function your_code() {
//code stuff
wait(1000); //waits 1 second before continuing
//other code stuff
}
console.log("Hello");
setTimeout(() => { console.log("World!"); }, 2000);