1

Have just found in https://github.com/douglascrockford/JSON-js/blob/master/json2.js the following way to declare and call closure:

(function() {
...
}()); <-- this part

as I used to the following one:

(function() {
...
})(); <-- this part

and actually many other libraries use the 2nd form.

What is the difference between them, and in which context they will be different?

Aliaksandr Kazlou
  • 3,221
  • 6
  • 28
  • 34
  • 1
    This is generally known as an Immediately Invoked Function Expression (IIFE). The difference of style isn't important. – shmuli Apr 20 '15 at 21:02

0 Answers0