Asynchronous Behavior in Loops: forEach() vs for...of - JavaScript

preview_player
Показать описание
#JavaScript #webdev #algorithms

Handling asynchronous behavior within a for-loop.

Source code at GitHub:

Social Media:
Рекомендации по теме
Комментарии
Автор

Looks like you solved the thing I've been looking for a whole fortnight....
It was my worst programming pain EVER.
Thanks so much for this.

MiSt
Автор

Dear, you saved my day!!! I was hanging in this error the entire day.

ibadshaikh
Автор

I guess for...of loop worked because you use async on the parent function, of which console.log(newArr) was part of or was present within that async function, which is not happening in case of a forEach loop. It is not an inherent behavior of for...of loop but the way you wrote code.

satindersingh
Автор

Thank you SO MUCH! I have breaking my head around this problem for 2 days until now!

eduardokiriakos
Автор

been on this one for almost 2 weeks....thanks sir. Keep up the good work.

fridayokorie
Автор

Great man nicely explained, was struck whole day & night deadline task

subhamroy
Автор

I've wasted all day hanging around this, even though I had the correct async await syntax. It was finally because of the fucking foreach. Thank you man!

nicolopezcesan
Автор

Just amazing... thank you even 2 years later

Howleyy
Автор

Thank you @Will Ward! My server uses python asyncio and websockets and it has a loop what is collecting the "online" status from the column of "usernames" from the database, push to frontend in json format, similar with your initial array. Every time when the front end got an update it had not updated the list just appended, but the console log worked fine. After I learned from you how to use the foreach properly with asynchronous updated. my "sidebar list" with " usernames" works as expected. Keep up the good work!

untildawn
Автор

Thank you man! I've been looking to sort this problem for quite a while, I didnt realize the forEach was the problem

charlydt
Автор

Thank you very much! This works amazing, you just saved my day. Great job!

adrianalfonsocanojaramillo
Автор

this is an ideal topic, you nailed it!

ismaelvarela
Автор

Thankyou so much sir i had been struggling the whole day because of the forEach, if it wasn't you this problem would've taken a week .

anshultiwari
Автор

Great! But one thing that made the video annoying is not using *easy keyboard shortcuts* 😩

sowmik.reborn
Автор

The solution I was looking for 😅. Thank you

AkashGupta-pccb
Автор

Dude, it's working I try for one day solving this error whenever I send response it went empty...now it's working fine..thank you so

nikunjjoshi
Автор

that was a life saver man thank you very much

digvijayyamagekar
Автор

I figured that out yesterday the whole day, i am here to find out "why" this happens

ruhan
Автор

Please, keep making more videos. probably just me, watching using file-> save, kills.

paappan
Автор

You're a freaking legend! thanks!

braxtonyoung