Function Construct in JavaScript



The (function() { } )() construct is an immediately invoked function expression (IIFE). It is a function, which executes on creation.

Syntax

Here’s the syntax −

(function() {
   // code
})();

As you can see above, the following pair of parentheses converts the code inside the parentheses into an expression −

function(){...}

In addition, the next pair, i.e. the second pair of parentheses continues the operation. It calls the function, which resulted from the expression above.

Updated on: 2020-06-16T09:15:21+05:30

2K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements