Why a different set up?


#1

Hello!

Why are we using two different set ups for JavaScript?

In the units we set up JavaScript this way:

$(document).ready(function(){});

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

var main = function() {};

$(document).ready(main);

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

Thanks !!


#2

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