Search code examples
javascriptfunctionparentheses

Enclosing parentheses in JavaScript


Could I get an explanation of the follow code snippet?

(function()
{
    alert();
})();

This looks like an anonymous function and the alert() function gets executed. I don't understand the semantic meaning of the outer parentheses. What does this part of the snippet mean?

(


 )()

Solution

  • this represents the immediately executable function. in easier way, it means that function being declared and called/executed simultaneously.