What is a Promise object in Javascript

Hi Friends,

I am struggling hard to understand Promise object in javascript as this has been asked to me multiple times in interview and every time I just pass this question.

I have gone through many articles on google but haven’t got the insight on this topic.

Can you please make me understand and it’s significance.

Thanks,
Ashish

Promises are for when you want to delay something until a requirement has been fulfilled.

Some good documentation on promises can be found from the MDN page on promises.

Paul, What is the async operations in javascript? like it is said in the documentation “The Promise object is used for asynchronous computations.”

Is it like I have made a ajax request to server and I want to show the loading sign…is it something like that?

Asynchronous operations are placed in a queue to be completed later on after the JavaScript has completed.

Hi Paul,

Can you provide me examples of async opeations…I am newbie to js.
Thanks!!
Ashish

AJAX would be the most obvious example. or anything you do in Node.js

As a beginner, the first thing you need to understand is what is going on in the core of most Javascript runtime engines, like in browsers or in Node.js. This video does a pretty good job explaining JS internals, especially the event loop.

Once you get that down and understood, then things like a promises should make a bit more sense. Basically, a promise lets you do asynchronous (and also synchronous) work and gives you the ability to better store and act on the results of that work.

Scott

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.