Posted by : Sudhir Chekuri Saturday, 10 March 2018

IIFE ( Immediately invoked function expression ) is a function that's executed as soon as it's created. It is a self invoking anonymous function. It has no connection with any events or asynchronous execution.

Syntax:

( function( ) {
     // Code goes here
     // ...
    } )( );

Explanation:

1.  ( function( ) {
     // Code goes here
     // ...
    } )( );

All the code inside the function will be converted into an expression.

2.  ( function( ) {
     // Code goes here
     // ...
    } )( );

The second pair of parentheses calls the function resulting from the expression.

Its most common usage is to limit the scope of a variable made via var or to encapsulate context to avoid name collisions.


Leave a Reply

Subscribe to Posts | Subscribe to Comments

Followers

Total Pageviews

Powered by Blogger.

- Copyright © 2013 DevStudent - Metrominimalist - Powered by Blogger - Designed by Johanes Djogan -