11

I commonly see both conventions and I'm wondering if there's an actual difference.

(function () {
  document.write("it works");
}());

(function () {
  document.write("it also works");
})();
GraxRabble
  • 119
  • 5

1 Answers1

1

There no difference between the two , The opening brace serves as a syntactic hint to tell the parser that what follows is a function expression instead of a function declaration.

for more http://jsperf.com/self-invoking-function

user2092317
  • 3,226
  • 5
  • 24
  • 35