What's a Promise?
A Promise is an object that acts as a placeholder for some value or operation that is soon to complete or return. Promises are similar to callbacks in that they are both used to control the execution order of a program. If you have 2 asynchronous (not occuring in any particular order) events A and B, and you need to ENSURE that Event B begins ONLY AFTER Event A completes, you can wrap Event A with a Promise object. This promise executes Event A and then gives you the option to either 'resolve' or 'reject' the Promise.
The Promise should be resolved if Event A was executed successfully with no errors. When a Promise is resolved, a special success callback function is triggered. This callback can execute Event B. A Promise should be rejected if Event A failed to complete successfully or produced an error. When a Promise is rejected, a special failure callback is triggered that can be used to carry out error handling tasks.
🌎 Find Me Here:
Twitter: / realdevsage
Ebooks: https://payhip.com/devsage
Discord: / discord
Merch: https://cottonbureau.com/people/devsage
Watch video Javascript Promises in 10 Minutes online, duration hours minute second in high quality that is uploaded to the channel DevSage 12 February 2019. Share the link to the video on social media so that your subscribers and friends will also watch this video. This video clip has been viewed 5,311 times and liked it 158 visitors.