- Name: optional, can be anonymous
- Code: invokable, you can RUN these code by ()
Create a object with NAME attribute and point to memory in the creation of execution context
Function expression (anonymous)
Create a object without NAME(already have a variable knows where this object lives) attribute and point to memory in the creation of execution context, and assign this object to function when this line of code is execute
Immediately Invoked Function Expressions (IIFE)
Create the function object on the fly and invoke it immediately, and assign what it return to the variable.
Why use iife and why it is safe
Code wrapped in IIFE does not interfere with, crash into, or be interfered by any other code included in the application.
In one function’s execution context, we have 1. Variable Environment 2. Outer Environment 3. “this”.
Q: How to control “this” variable?
We should think and code in terms of functions