Callback vs. Promise (JS)

They are used to handle asynchronous (single-threaded) execution.


Callback (Old school)
A Callback is a function
… that gets injected into another function as an argument
… and executed from within that function for further operation.

Example (see XHR)


Promise (New School)
A Promise is an object
… that gets returned by an asynchronous function
… which represents the current state of the operation.

Async/Await … is just syntactic sugar to handle promises.

Example (see Fetch)