Async - Callbacks

Context: https://www.codecademy.com/courses/learn-intermediate-javascript/lessons/async-await/exercises/introduction

In the above exercise, the lesson notes the following: “Originally, JavaScript used callback functions to handle asynchronous actions. The problem with callbacks is that they encourage complexly nested code which quickly becomes difficult to read, debug, and scale. With ES6, JavaScript integrated native promises which allow us to write significantly more readable code.”

My question is this; should promises be used all of the time now instead of callback functions or only where code should run asynchronously? i.e. have promises and async now fully replaced callback functions from a readability standpoint?

Thanks

1 Like

A follow on to the above question:

It looks like async await is the way to go now instead of callbacks (again if someone could confirm that this is always the case or if it is just the case when reaching out to a library etc).

Are promises still needed and used when, for example, creating a library? i.e. if you were building an API, would you be creating promises or can you also use async in your library to return a promise to a client?

I hope that all makes sense, it might sound a bit confused because I am still working through it!