I am currently debugging some code right now but I cant get myself around this concept in javascript.
I have this code construct.
if(!COMPANY)
COMPANY = {};
COMPANY.Billing = (function(COMPANY){
//More code
})(COMPANY);
As, i understand, it creates an object called "COMPANY" and then adds a new property called "Billing" but I dont understand the idea of passing the same "COMPANY" into the arguments of the function and at the same time renaming it to "COMPANY" again. What I mean is what is the difference between the code above and the code below.
COMPANY.Billing = (function(COMPANY){
//More code
})();
My javascript is not that deep so I would like to understand what the code construct above means. This might be some javascript design pattern but I dont know what it is