

Spoiler: JavaScript never really "pauses". In this post, I'll discuss how you can achieve that and what it really means to "pause" or "sleep" in JavaScript. One of those features are Promises, which are probably the most widely used feature in JavaScript after ES5 was released.īut one of the things which JavaScript misses is a way to "pause" execution for a while and resume it later. To transform seconds into milliseconds you will need to multiply your seconds by 1000. To complete this task, first of all, you will need to transform seconds into milliseconds. Exceptions Throws the rejection reason if the promise or thenable object is rejected. Luckily for us, JavaScript provides a few ways for a developer to wait X seconds before executing the next line of the code. Return value The fulfillment value of the promise or thenable object, or, if the expression is not thenable, the expression's own value. More and more ideas and features are being ported from different languages and being integrated in JavaScript. Syntax await expression Parameters expression A Promise, a thenable object, or any value to wait for.

And it hasn't been the same since ES5 was released.
