> 
> **Possible Duplicate:**  
> 
> [Self Executing function doesnt work?](https://stackoverflow.com/questions/7978219/self-executing-function-doesnt-work) 
> 
> 
> 

In Javascript, why does

```
function() { console.log('hello'); }();

```

give an error, but

```
function() { console.log('hello'); }()

```

not?

Edit: some answers state that both give syntax errors in Firefox, but this does not seem to be the case in either Chrome or a Node.js REPL. Additionally,

```
(function() { console.log('hello'); }());

```

seems to work fine in Firefox.