Promises
resolve, reject, then, catch, async, await.
A Promise in JavaScript is just like CompletableFuture in Java. The one difference is the threading. JavaScript is single-threaded. Java is multi-threaded. The same thread runs the code and the async tasks.
You use it to start async work. You then tell the executor which functions to run when that work is done. You don't return anything. You just run something else once the first async step finishes.
When the async work is done, it calls the functions on the Promise object. These ask the engine to resume the paused main code. The result is put back where the async work was called.
When the compiler sees an async function, it swaps in a state machine. The current run is paused. Its state is stored on the heap. When the async work is done, the state machine uses this heap object to resume right where it stopped.

resolve and reject
A Promise constructor takes one thing, the executor. This is the function to run in async mode. The executor takes two functions as parameters: resolve and reject.
The Promise object structure is part of the JavaScript spec. Any JavaScript engine must have a constructor like the one above.
These are private methods. The engine runs them when the executor succeeds or fails. They set the inner properties of the Promise to show the state. They also store the result object.
resolve and reject are system functions. The language spec names them. Any JavaScript engine that follows the Promise rules runs them.
then and catch
After the promise resolves or rejects, the functions in then and catch run with the right parameters.
The engine puts the then and catch callbacks in the callback queue. It does this as soon as the Promise state changes.
async and awaits
A function marked async returns a Promise object.
You get this without calling the new Promise() constructor.
async function f() {
return 1; // can be anything. Need not be a real asynchronous function such as setTimeout() or fetch().
}
f().then(alert); // 1
The await statement makes JavaScript wait until the promise settles. Then it returns the result. You get the resolved value without a then.
You can use a normal try-catch block to get the rejected value.
async-await's mostly syntactic sugar over promise-then-catch. It makes the code easier to read.
Promise.resolve() and Promise.reject()
These are static helper methods. They return a Promise object with the state and value already set.
This helps when a method must always return a Promise but has no real task. For example, when you return a value from a cache but the return type is always a Promise.
Use the caching example to understand these static helper methods.