tags:

views:

76

answers:

2

Possible Duplicate:
Explain JavaScript's encapsulated anonymous function syntax

I've seen this code:

( fab.nodejs )
     ( function() { this({body: "my app" })(); })

I wonder what the outer parenthesis do?

+2  A: 

The parenthesis will ensure that the function is treated as a function expression instead of a function declaration (aka function statement). You may want to check out the following article for further reading about the difference between a function expression and a function declaration:

Daniel Vassallo
A: 

similar question

It is a self-executing anonymous function. The first set of brackets contain the epxressions to be executed, and the second set of brackets executes those expressions.

JapanPro