Promise vs Callback in javascript


Promises and callbacks are very basic concepts and every javascript developer should know the difference.

Let's try to understand with a small example:

someWork() is a function that is going to take roughly around 2 seconds and we want to execute otherWork() function once someWork() is done. This can be achieved using a Callback or Promise.


Here we pass otherWork() function as an argument to someWork() function.

someWork() function will call otherWork() function after its work is done.


Here someWork() function return promise object which can be resolved(success) or rejected(error). We can call otherWork function in .then.

Share this with anybody you think would benefit from this. Have any suggestions? Feel free to message me on LinkedIn.



Riddhesh Ganatra

Software Architect, Full Stack Web developer, MEAN/MERN stack, Microservices, etc