We're a place where coders share, stay up-to-date and grow their careers.
I seldom use IIFEs, but I like your idea of prefacing with void. I typically name the function "iife" as well. (or iife1. iife2...)
void
I find myself using them more often for generators or async generators, like that getRacers from the article:
getRacers
await Promise.race(function* getRacers() { for (const p of iterablePromises) { if (!p?.then) throw new TypeError(); const settle = () => winner = winner ?? p; yield p.then(settle, settle); } }());
I seldom use IIFEs, but I like your idea of prefacing with
void
. I typically name the function "iife" as well. (or iife1. iife2...)I find myself using them more often for generators or async generators, like that
getRacers
from the article: