Javascript - What is a Function within parentheses for?

Asked

Viewed 249 times

0

One of these days I saw a code on javascript and I wondered why use parentheses to close a Function:

(function(){

});

Like this code above. I appreciate any explanation.

  • 3

    The name of it is IIFE (Immediately Invoked Function Expression). This indicates that once Javascript creates the function, it will run. (function(){
/* Code */
})();

  • Hmm interesting, thanks for the help.

  • See if the links in the yellow box up there clarify you. If not, let us know here.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.