A promise is like a special kind of note that tells you something will happen later, and it helps you keep track of when it does.
Imagine you're waiting for your favorite snack after school. You leave a note on the kitchen table that says, "I promise I'll eat my snack at 4:00 PM." That note is like a promise, it tells you something will happen (you'll get to eat your snack) and when (at 4:00 PM).
How a Promise Works
When you write the note, you're making a promise. The person who reads the note (maybe your mom or dad) knows what's coming next.
If you're using promises in computer land, it's like telling the computer, "I promise I'll give you this snack at 4:00 PM." Then, when the time comes, the computer can do something else, like play a game, and come back later to get your snack.
You don’t have to wait for the snack right then, you can keep playing while the promise is being kept. That’s how promises help computers work smoothly without getting stuck waiting for one thing after another.
Examples
- Your friend might not always bring the ice cream, so promises can also fail.
Ask a question
See also
- What is Single Page Applications (SPAs)?
- What is await?
- What are magical promises?
- What are asynchronous operations improperly synchronized?
- How do AI deepfakes trick people so easily?