Why a different set up?



Why are we using two different set ups for JavaScript?

In the units we set up JavaScript this way:


But in the projects it's set up this way:

var main = function() {};


Why is there a difference and which is best to use?

Thanks !!


Maybe there's more to it than this, I know nothing about web development.

If you don't want anything to happen when your page has loaded, you'd supply a function that does nothing.
But if something's supposed to happen when everything else is in place, start a game? Then supply a function that does that