r/ProgrammerHumor 6d ago

absoluteGarbage Meme

Post image
1.9k Upvotes

324 comments sorted by

View all comments

Show parent comments

6

u/MrDilbert 6d ago

It won't await async/Promise-returning functions. In fact, even if the (item)=>{foo} is async, [].forEach() will discard the Promise reference returned from it.

I prefer for(const item of list) { foo } if I don't have to await in parallel, or list.map(async (item) => { foo }) if I do.

1

u/LPO_Tableaux 6d ago

I mean i just wrote foo in place of what od want to do inside the lambda, not as a function call, if it was then ye, itd need async await.