0

What is the difference between these two types of running a JavaScript function?

(function() {
    //Code #1
})();

and

(function() {
    //Code #2
}());

I've seen both of these and i tend to use the #1.

daniels
  • 18,416
  • 31
  • 103
  • 173

2 Answers2

1

There is no functional difference at all... just a manner of style.

Brad
  • 159,648
  • 54
  • 349
  • 530
1

None -- they are both self-executing anonymous functions which hide variables from the parent namespace.

jeff
  • 8,300
  • 2
  • 31
  • 43