Posted 2 years ago
Promise.all()function with that promise array as the input parameter. then it will dispatch all the promises at once and after all the promises are fulfilled it will resolve an array of objects with the fulfilled individual promises.
gist:RizkyRajitha/721ce1f1e8f6ed0a9f368c3de821a3dakeep in mind that this is all of it or none at all. So even if one of the child promises got rejected, we will get the whole thing (parent promise) rejected.
array.forEach()right. But the thing is you cannot use
array.forEach()so, let’s say after meeting a specific condition your
forEachloop needs to stop. But you can’t do it in
forEachloop. That’s where our friend
for (let item of array)comes. This does exactly what
array.forEach()do, but we get the option to
forloopanytime we want in any breakpoint. Of course, you can use a regular for loop for this. But this is a pretty clean way to get the job done