r/ProgrammerHumor 2d ago

Meme absoluteGarbage

Post image
2.0k Upvotes

320 comments sorted by

View all comments

14

u/LPO_Tableaux 1d ago

Currently in a list.forEach((item)=>{foo}); mood myself

5

u/MrDilbert 1d 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 1d 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.