Difference Between Promises & Callbacks

Promises are not Callbacks. A Promise is a value which may be available in future or not. A Callback is a function which we call inside other function. Normally callback runs after the parent function completes its operation. Let’s say the function is sending AJAX query, we can use callback function in a way so, when the AJAX request gets response, we can use the response in the function to do some other operation. In case you are interested to

Continue Reading

Introduction to Javascript Promises API

Javascript Promises API

A Promise is a value not necessarily known at the time of it’s creation. It mainly used in asynchronous actions resulting in success or failure. The Promises represents a value which may be available now, or in the future, or never. Promises new Promise(function(resolve, reject) { }).then(function() { }).catch(function() { }); then() and catch() are prototype methods and they can ben chained as shown above. A Promise will always be either “Pending” or “Fulfilled” or “Rejected”. Pending – Initial state, operation not

Continue Reading