In simple words what is the promise?
If we discuss about the dictionary meaning of promise, you will get what exactly promise does-
"to tell someone that you will certainly do something:", but promise isn't limited to the dictionary meaning, it has stages and promise is an javascript object that portray result of a condition - either fail or pass.
If you open a book , you search for a topic, you will either get it or not,the same thing applied to promise also. We are discussing here the promise methods which are also known as promise patterns, but Here stage is important before we deep dive and swim into the methods, lets see the code example.
As we know,you don't know js and me too, i also don't know js and excepting is not a problem and let's subtract using the promises.
/* Promise.all([])-> it can handle all the array of promises and all should be passed here , one fail the promise will be rejected,it's similar to your 12 exam,if you fail on one subject, you will be considered as overall fail.
and if you pass on all subjects and you will be considered pass on every subject. We will obtain one response.
*/
what will happen when our promise fail?
We need another arrow function which follow these task as presented on the code.

Promise.race([p1,p2,p3])-> There is requirement of one player to win the game ,and others can loose the game.
In this code, i have handled only one race condition, or only one player and readers who like to code,they should handle the second promise, if anyone feel stuck comment on the blog, i will provide the solution.
We passed delay function, to the race function, but in case of race function,the only one player will be win and race returns the first settled promise, others doesn't matter.
Promise.any([])- returns the first fullfilled (passed) promise.
Promise.allSettled() - It is similar to all promises are settled into one array,you will get all the information of available promises into one array.
Promise.finally()
Finally() always runs after promise, basic purpose is the cleanup of the code.
////////// cooking the blog ///// wait







Top comments (0)