Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

why this way "this.foo = new (function () {..})();" vs. "this.foo = function (){...};"

Tags:

javascript

Is there any difference in the two definitions and assignments of functions?

this.foo = new (function () {..})();

vs.

this.foo = function (){...};
like image 855
Xerion Avatar asked Aug 16 '10 16:08

Xerion


1 Answers

In the first example, it's creating a function and executing it, assigning the result to this.foo. In the second example, it's creating the function and assigning the function itself to this.foo.

like image 190
Kiersten Arnold Avatar answered Sep 18 '22 09:09

Kiersten Arnold