I'm trying to understand the difference between:

```
(function(document) {
    //do stuff with document
})(document);

```

and

```
(function() {
    //do stuff with document
})();

```

I'm unsure why the convention appears to be to pass `document` and sometimes `window` too to the function? Is it to do with scope?