![]() |
Immediately Invoked Function Expressions (IIFE) are JavaScript functions that are defined and immediately invoked. They are wrapped in parentheses to turn them into expressions and followed by an additional pair of parentheses to invoke them immediately after declaration. Syntax:(function() { Key characteristics of IIFE:
Example: Here, the function is immediately invoked after its declaration, and the code inside it runs immediately. This pattern helps in keeping variables within a local scope and avoids conflicts with variables in the global scope. Javascript
Output
Hello, World! |
Reffered: https://www.geeksforgeeks.org
JavaScript |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 12 |