Синхронизация JS

function wait(ms) {
    const start = Date.now();
	let now = start;
    while ( (now - start) < ms ) { now = Date.now(); }
}

// Usage:
console.log("Before wait...");
wait(5000);
console.log("After 5 seconds...");
KostasX