The General Syntax:
/ / . . .
- It is enclosed within a grouping operator() as an anonymous function with its own lexical scope.
- This prevents outside access and also polluting the global scope.
There are two problems with this:
- It will likely cause name collisions.
One way to prevent the functions and variables from polluting the global object is to use immediately invoked function expressions (IIFE).
It is called an immediately invoked function expression (IIFE) because the function is created as an expression and is executed immediately.