What is the JavaScript equivalent of sleep(), and how can I implement an actual pause in code execution?

The pausecomp() function you found is basically a busy wait loop. It does pause execution, but it blocks the entire browser thread while doing so:

function pausecomp(millis) {
  const date = new Date();
  let curDate = null;
  do { curDate = new Date(); }
  while(curDate - date < millis);
}

It does work, but it’s like hitting the brakes on your app. Your UI freezes, animations stop, and users can’t interact with anything while it’s running.

Great for testing or niche uses, but not for real-world applications.