What is Promise function in javascript?

Forums JavaScriptWhat is Promise function in javascript?
Staff asked 3 years ago

Answers (1)

Add Answer
Umang Ramani Marked As Accepted
Staff answered 3 years ago

In JavaScript, promises are used to handle asynchronous operations. They are simple to handle when dealing with several asynchronous activities when callbacks might lead to unmanageable code.

Prior to promises, events and callback functions were utilized, but they were restricted in functionality and resulted in unmanageable code.

Multiple callback functions would result in callback hell, resulting in unmanageable code. It is also difficult for any user to manage many callbacks at the same time.

Syntax :

var promise = new Promise(function(resolve, reject){
     //do something
});

 

Subscribe

Select Categories