Lannie Rose
1 min readApr 15, 2020

--

Really this is all about anonymous IIFEs, right? Because there is the simple case where I actually want to execute a named function immediately after I define it. Of course I can do that without IIFE, just invoking the function by name after defining it, but IIFE is more compact and makes the intent more obvious. I also like the construct !function fname(){…}() for this purpose. There was a time that I even understood why it works. So maybe not so obvious, if you don’t know the trick, but cleaner by eliminating the outer parens which are visually kind of ugly and confusing IMHO.

--

--

Lannie Rose
Lannie Rose

Written by Lannie Rose

Nice to have a place where my writing can be ignored by millions

Responses (1)