Skip to content
Justice Tech School

Promises

A promise stands for a future value. Use then, catch and finally, or await.

Example
const p = new Promise((res) => setTimeout(() => res(42), 10));
p.then((v) => console.log("got", v)).finally(() => console.log("done"));
Promise.reject(new Error("no")).catch((e) => console.log(e.message));

Result

no
got 42
done

Exercise

Handle errors.

p.(handler)

Quiz Test

What does Promise.all do?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.