Comment

The Bob Cesca Podcast: Space Alien In A Human Suit

27
Charles Johnson6/13/2024 5:03:38 pm PDT

An interesting thing about Javascript’s async/await pattern is that it actually can bring back old school types of looping structures, because forEach() loops cannot execute asynchronously and that means when you start a forEach() loop the rest of the code after it just keeps executing, so things can get all screwed up. So when I need a loop to run completely before the rest of the code executes asynchronously it needs to be a creaky old “for/next” loop, or one of the newer “for” commands for iterating over objects (“for/in” and “for/of”). Then nothing else can run until the loop finishes.

This has been a random nerdish timeslice.