Skip to content

Tag: iife

How are IIFEs useful post ES6?

I’m learning JavaScript and I understand the general function types, closures, etc. But with IIFEs my initial reaction was “if its immediately invoked, why not just inline it”. So I went and read this article that describes “4 Practical Use Cases” for IIFEs. However, two of which…

Why does a named IIFE result in a ReferenceError outiside of it?

Why did I get “ReferenceError: Person is not defined” for the following code? Since function Person is run, it is first created. However, I cannot explain why it is not then recognized. My only thought is that IIFE ignores the name they are given. Answer You get the error because the name of a function create…