Promises in Javascript

User
Posted by luhan
11 months ago in General Discussion
137 views
5 replies
User
luhan
Posted 11 months ago

This thread will be talking about `promises` and this is a continuation of the async functions post. Click on this link "https://afr.ng/8cf2385e" if you haven't read the async/await post.

So JavaScript is all about keeping things moving, but sometimes you have got to wait for something to finish. Promises are here to ensure you don't get stuck in code limbo!

**What are Promises?**

Promises are objects that represent the eventual completion (or failure) of an asynchronous operation. They act like a placeholder, saying "Hey, I'll get you the result when it's done."

**Think of it like an order:** Imagine you order a pizza. You don't get it right away, but the restaurant gives you a receipt (the promise) saying they'll deliver it eventually. The receipt tells you it'll be delicious (resolved promise) or burnt (rejected promise).

Image preview

Replies (4)

Please login to post a reply.

Thread Actions
Related Tags