It is a design pattern which is also known as Self-Executing Anonymous Function and contains two major parts. The first is the anonymous function with lexical scope enclosed within the Grouping Operator (). This prevents accessing variables within the IIFE idiom as well as polluting the global scope.
Immediately Invoked Function Expression (IIFE)
- Avoid Creating Global variable and Functions
- As it doesn‟t define variable and function globally so there will be no name conflicts
- Scope is limited to that particular function
Pass by Value
- If a function changes an argument’s value, it does not change the parameter’s original value.
- Changes to arguments are not visible (reflected) outside the function.
Pass by reference
- Because of this, objects will behave like they are passed by reference:
- If a function changes an object property, it changes the original value.
- Changes to object properties are visible (reflected) outside the function.
Latest posts by rajeshkumar (see all)
- Git Error: Filename too long - May 15, 2023
- Oracle RAC: Script that duplicates a database using a physical standby RAC as source - May 15, 2023
- Protected: oracle-rac-fixes - May 11, 2023