It creates a closurepersonal area hiding variables fromglobal object
var x = 2;
...
...
var x = "foo"
alert(x);
But when you use closure:
var x = 2;
(function (){ var x = "foo";})();
alert(x);
In terms of syntax, it's just a self-starting function, you declare it and execute it.
source
share