How to work with javascript promises?

Example:


  let promise = new Promise((resolve, reject) => {
      setTimeout(() => resolve("done!"), 1000);
  });
  

Solution:

A Promise in JavaScript represents a value which might be available now, or in the future, or never. It allows you to associate handlers to an asynchronous action's eventual success or failure.

Beginner's Guide to JavaScript