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.
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.
(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/