Loading…

How can we avoid callbacks?

We can avoid callback hell by different available solutions, as mentioned below.

Promises: The promise is s result of an asynchronous operation. We can create a promise on these three states:

  • Pending: When the initial state is not fulfilled or rejected.
  • Fulfilled: When the operation gets completed successfully.
  • Rejected: When the operation gets failed.

Generators: These are functions which can be resumed and paused. It doesn’t get executed immediately when called. Instead, it returns a generator object or generator object with which we can control the execution of the function.

Suggest An Answer

No suggestions avaliable!

Latest post from Node js Interview Questions

Ask Question