1
(function f() {
    // do something
}());

vs

(function g() {
    // do something
})();

Note the position of the ending parentheses.

  1. Do these execute in the same manner?
  2. Do they restrict the scope of variables differently?
geg
  • 4,399
  • 4
  • 34
  • 35

1 Answers1

1

They are the same. Just two notations to do the same thing. Some people find one notation more intuitive than the other. Just a matter of preference, nothing more than that.

Aravind
  • 3,169
  • 3
  • 23
  • 37