I think Promise.all executes concurrently not in parallel. A true parallel means like running task simultaneously on 2 threads. In JavaScript it can be done using web worker. Also can you explain in Promise.all where the settled promise are stored till other promise are still pending? It was asked in an interview. Your videos are wonderful keep making...
Great content and such an elegant code but just one clarification, we can run promises parallely using promise.all() (fail fast) and promise.allSetteled() too right? And this example can be done using allSetted so if the interviewer asks to show parallel promises then which to show this code(which is simple and great explanation) or allSetted?
Hi Prashant does promise.all and promise.settled execute async task parallely or concurrently. I have seen this question asked in many interviews . Want to know what should be we answer if this question is asked in interview
If the response comes randomly this means they are run parallelly else if they return in input order then its concurrently. Now monitor the reponse of both yourself.
Prashant, But in promise.all the result comes in the same sequence as provided in the input array but it calls all the async tasks parallelly. And that is because of Results[index] = value It uses index instead of push
I think Promise.all executes concurrently not in parallel. A true parallel means like running task simultaneously on 2 threads. In JavaScript it can be done using web worker.
Also can you explain in Promise.all where the settled promise are stored till other promise are still pending? It was asked in an interview. Your videos are wonderful keep making...
Great content and such an elegant code but just one clarification, we can run promises parallely using promise.all() (fail fast) and promise.allSetteled() too right? And this example can be done using allSetted so if the interviewer asks to show parallel promises then which to show this code(which is simple and great explanation) or allSetted?
Anythings works as long as it gives desired result
Thanks for Sharing 🚀
Well explained 👍
very helpful
Hi Prashant, I am not able to differentiate between this question and the prev one(async task in seq) could you please elaborate a bit
In sequence second promise will start executing only after first is settled
In parallel, All promises are executed parallelly
Hi Prashant does promise.all and promise.settled execute async task parallely or concurrently. I have seen this question asked in many interviews . Want to know what should be we answer if this question is asked in interview
If the response comes randomly this means they are run parallelly else if they return in input order then its concurrently. Now monitor the reponse of both yourself.
Prashant, But in promise.all the result comes in the same sequence as provided in the input array but it calls all the async tasks parallelly.
And that is because of
Results[index] = value
It uses index instead of push
@@TechnoMob ohh, i see
Great video Prashant! I wanted to know what is the difference between this approach and using promise.allsettled. thanks and keep them coming :)
Nothing, this is polyfill for settled
@@Learnersbucket thanks for the clarification.