Promise is another popular term you would have heard before. By definition, "Promise is a future value.", meaning a promise represents a placeholder for the result of a computation, the value of which will be determined at some point in the future. Technically speaking, this value may or may not be made available in the future, implying that the computation may either resolve or reject at some point in the future.
The definition subtleties aside, if you think about it, promises are very similar to callbacks. When we pass a callback to a function, we rely on that function to call the supplied callback at some point in the future. The callback either gets called back with an error or with the result of the operation. Similarly, with promises you rely on the promise to either resolve
or reject
at some point in the future.
Promise can be thought of as a callback that calls the resolve
function with the result of the operation in case of successful computation, or calls the reject
function...