Categories
Mastering Development

Why does `then` even exist and when should it be used?

If one of the goals with Promises is to prevent callback hell, why does then even exist and when should it be used?

Example:

//If this
someFunction.then((retunValue) => {

});

//Can be written like so:
const returnValue = await someFunction();

Why would anyone choose to write it the first way?

When should then be used today?

Leave a Reply

Your email address will not be published. Required fields are marked *