News for hackers. Stuff that matters.
Re:FP techniques that will help you write better JavaScript by ablu on Friday February 11, 2022 @03:26AM (#30298679)
I think `for element of list` nowadays starts to become a realistic choice (without a transpiler) for that: https://caniuse.com/?search=for...of
Re:FP techniques that will help you write better JavaScript by cehrlich on Friday February 11, 2022 @04:37AM (#30299293)
As an added benefit, `for...of` works with async, unlike forEach.
Re:FP techniques that will help you write better JavaScript by dragonwriter on Friday February 11, 2022 @02:25PM (#30305901)
If I would be tempted to use forEach but can’t because async, I usually don’t want for…of semantics, though. I probably want something like

  await Promise.all(collection.map(thing => some_async_function(thing)));
instead of:

  for thing of collection {
    await some_async_function(thing);
  }