I have come across a self executing function that executes on a condition that the declared containing var exists, and if it doesn\'t exist it is passed an object.
Exam
var myFunc = (function(myFunc){}(myFunc||{}));
This doesn't make any sense because the myFunc Argument will always be {}
- I'm confused by that.
Ill explain one that does
First Example
var cool = {
person: 'john'
};
(function( Argument ){
console.log( Argument ); // Result Object {person: "john"}
}( cool || {} ));
In this example cool is defined and is a object so it wont go past the ||
Next example
var cool;
(function( Argument ){
console.log( Argument ); // Result Object {}
}( cool || {} ));
In this example cool is defined But the defualt value for a variable is undefined
so in this case it is undefined so Argument is a Object instead