What is the difference between the following 2 examples of code:

```
(function(){
    var myFunc = (function(){
        //do something
    })();
    window.myFunc = myFunc;
})();

```

and 

```
var myFunc = (function(){
    //do something
})();

```