promises - mmedrano9438/peripheral-brain GitHub Wiki

Promises are a way to implement asynchronous programming in JavaScript(ES6 which is also known as ECMAScript-6). Promise acts as a container for future values. Like if you order any food from any site to deliver it to your place that order record will be the promise and the food will be the value of that promise.

const myPromise = new Promise((resolve, reject) => { if (Math.random() > 0) { resolve('Hello, I am positive number!'); } reject(new Error('I failed some times')); })

Promises