promise
Docs
1. Promise - JavaScript | MDN
The Promise object represents the eventual completion (or failure) of an asynchronous operation and its resulting value.
A Promise is a proxy for a value not necessarily known when the promise is created. It allows you to associate handlers with an asynchronous action's eventual success value or failure reason. This lets asynchronous methods return values like synchronous methods: instead of immediately returning the final value, the asynchronous method returns a promise to supply the value at some point in the future.
3. Promise
Videos
JavaScript Promises In 10 Minutes - YouTube
let p = new Promise((resolve, reject) => {
let a = 1+1;
if (a == 2) {
resolve ('Success')
} else {
reject ('Failure')
}
})
p.then(message => console.log('Hello there ' + message))