I've stumbled upon a pretty elegant way to structure JS Code for a page, though I'm not really sure why it works the way it does. Could someone explain to me how this works? (Why is that return statement there for example).
Also is there a name to describe a pattern like this?
var PageCode = (function () {
return {
ready: function () {
console.log('document.ready');
},
load: function() {
console.log('document.load');
}
};
}());
$(document).ready(PageCode.ready);
$(window).load(PageCode.load);