Can you keep a Promise()?
Daddy can you keep a Promise()?
This is a story about Promises. The ones you must keep if you care about the people who rely on you. This article is a nice story about promises which are very relevant to JavaScript. It refers to callback functions and Promises.
The Promise object is used for asynchronous computations. A Promise represents a value which may be available now, or in the future, or never. A callback is any executable code that is passed as an argument to other code, which is expected to call back (execute) the argument at a given time. This execution may be immediate as in a synchronous callback, or it might happen at a later time as in an asynchronous callback.
Leaving the Story aside, callback is not a feature of ES5. It is important to know that callbacks are in fact an implementation of first class functions. The bad side of callbacks is that their execution is coupled with the function to which they are passed. A Promise, on the other hand, is a feature implemented in ES2015. The idea behind it is based on callback logic, but the final result is quite different. A Promise will be resolved or rejected, it doesn’t actually know what will be implemented in a then() or catch(). That scenario makes it more decoupled when compared to a callback implementation.
At the end, there is something even better and it’s called async / await functions.
Read Promises by @develoger
So… listen to your child, give and keep Promise(). Since sometimes calling back is just not enough.