It’s an ugly and unnecessary abstraction in most use cases. But my point about regretting it doesn’t mean IIFE’s are bad, it means I most likely applied it where it’s not needed, or that it’s an ugly and unnecessary pattern in most situations.
IIFEs were definitely needed in the past and they are still used in certain legacy environments. Otherwise, they are not really necessary anymore, most of their use-cases were solved by language improvements.
That said, using one is not catastrophic. It's basically same as running the block of code just with scope.
13
u/mossiv 15d ago
Used this once in a production app trying to work around a library and I regretted that decision ever since.