Promises

A promise is an object representing the eventual completion or failure of an asynchronous operation.

Snippet:

const promise = new Promise((resolve, reject) => { /* code */ });

Example:

promise.then(result => console.log(result)).catch(err => console.error(err));