I am new to Javascript and want to become familiar with best practice.
Today I came across a new construct that I need the communities help in understanding. The code relies on Jquery. The construct is as follows.
$(function() {
var data = {
//
};
var cont = {
//
init: function(){
}
};
var view = {
//
};
cont.init();
}());
My understanding of this is that an IIFE is being passed into the JQuery namespace.
What is confusing me though is that the code only contains 3 literals and no return statement. You see I am looking at this from the point of view of module patterns. In that, a module used in an IIFE would return an object literal containing any intended public functions.
This code does not return an object. Are in fact, the 3 object literals (data,cont,view) simply being added to the JQuery namespace? Yet, another part of me thinks that this would simply return undefined
to the JQuery namespace. Please advise.