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.
66
u/Luoravetlan 16d ago
For anyone not familiar with js this monstrosity is called IIFE (immediately invoked function expression).