JavaScript Async/Await Pitfalls With ForEach
Build bug-free apps
Published in
2 min readFeb 26, 2021
A common pitfall in JavaScript is the usage of async/await
in combination with forEach
. Let’s look at an example with a simple asynchronous function (asyncPrint
) that prints a value to the console. Say we want to call it sequentially for every value in an array via forEach
: