JavaScript wartete 1 Sekunde
setTimeout(function(){
console.log("Ready")
}, 1000);
Foreverekk
setTimeout(function(){
console.log("Ready")
}, 1000);
function sleep(milliseconds) {
const date = Date.now();
let currentDate = null;
do {
currentDate = Date.now();
} while (currentDate - date < milliseconds);
}
console.log("Hello");
sleep(2000);
console.log("World!");
wait(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
setTimeout(() => { console.log("2000 milliseconds later!"); }, 2000);