Member-only story

Javascript Promises: Javascript Interview questions #9

Melih Yumak
4 min readJun 16, 2022

--

Promises in javascript — Interview Questions # 9

What are the promises and how can we use promises in javascript?

Hello everyone, in this tutorial we will learn about how to use promises, promise chaining, and importance of promises in javascript with examples.

There are many synchronous and asynchronous operations in javascript. Promises are used to handle asynchronous operations. With the help of promises we can check if the asynchronous operation has been succesfully completed or failed.

Promises has three states

  • Pending
  • Fulfilled => Resolved
  • Rejected => Failed

When we start call the promise it starts with pending state.
Pending state means the operation still continues.

If the promise successfully finishes without any erros promise ends with fulfilled state.

If there are some errors occurs on the process promise ends with rejected state.

As an example lets assume we are sending a request to a server to fetch a data using promise it will start with pending state. If data returns back successfully, promise state end with fulfilled state or…

--

--

Melih Yumak
Melih Yumak

Written by Melih Yumak

Top Technology Writer — Lead Full Stack Software Engineer — Youtuber https://www.youtube.com/c/TechnologyandSoftware

No responses yet