DEV Community


Discussion on: A few handy JavaScript tricks

morganconrad profile image
Morgan Conrad

I seldom use IIFEs, but I like your idea of prefacing with void. I typically name the function "iife" as well. (or iife1. iife2...)

noseratio profile image
Andrew Nosenko Author

I find myself using them more often for generators or async generators, like that getRacers from the article:

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);
Enter fullscreen mode Exit fullscreen mode