0
var x = (function () {

some code

})();

What this kind of expression called, what does it mean? This part defined a object and include some function inside. I am confused about why there need to be a () in the end.

user7227316
  • 51
  • 2
  • 3

1 Answers1

0
(function () {

some code

})();

Above code is self invoking function (IIFE). var x= IIFE will assign the value reutrned by IIFE to x.

Here is great post explaining IIFE http://benalman.com/news/2010/11/immediately-invoked-function-expression/

Kumar Nitesh
  • 1,634
  • 15
  • 18