When you’re writing code in JavaScript and you need your function to wait some time, you usually use setTimeout(callback, millis). The problem with this function is that only the callback will be delayed, while the code next to it will run normally. How do you actually stop the execution of the application for a certain amount of time, like Java’s Thread.sleep() does?

You can do that thanks to ES8.

(more…)