My FeedDiscussionsHeadless CMS
New
Sign in
Log inSign up
Learn more about Hashnode Headless CMSHashnode Headless CMS
Collaborate seamlessly with Hashnode Headless CMS for Enterprise.
Upgrade ✨Learn more

How does JS keep its Promises?

Subhasree Vadukoot's photo
Subhasree Vadukoot
·Jun 2, 2021·

1 min read

How does JS keep its Promises?

Promises is a core language feature that makes Asynchronous programming with Javascript simpler. Promises allow us to work with callbacks in a different manner, by asking the Promise to call the callback function we need.

Imagine a scenario where your friend has promised to accompany you on the day of your driving test to boost your confidence.

Two things can happen

  1. Promise is kept and you are happy
  2. For some reason, your friend didn't keep the promise.

In JavaScript, this equates to :

  1. Promise is fulfilled
  2. Promise is rejected

References