DevOps Engineer | Full Stack Developer | Building Cloud Native Apps | Working with Linux, AWS, Kubernetes, React, Node.js & TypeScript | Open to Remote Roles
I'm not sure if you're asking why use map over for-loops but if you are, checkout out this post. You can scroll down to the "Benefits of map over for loops" section.
I use Promise.all when the order of my async functions to be resolved is not important but I need them all to be resolved before I can go on.
One use case for getting a promise back is if you are uploading a bunch of files and you want to check if any of them failed and do some operation to either auto try that specific one or help the user figure out which one failed.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Why not just use an old-school for-loop? Easy-peasy, problem solved and my promises resolve in the order I call them; unlike Promise.all()...
Genuinely asking.
I'm not sure if you're asking why use
map
over for-loops but if you are, checkout out this post. You can scroll down to the "Benefits of map over for loops" section.I use Promise.all when the order of my async functions to be resolved is not important but I need them all to be resolved before I can go on.
One use case for getting a promise back is if you are uploading a bunch of files and you want to check if any of them failed and do some operation to either auto try that specific one or help the user figure out which one failed.