var myObject = window.myObject || {};
That declares myObject
on the global scope. If it was existing before it takes the existing value, or if it is not existing it assigns it to a new empty object (Read on). This is a common technique if multiple scripts assign properties of the same object, so that it doesn't matter which script got executed first they will always end up with the same result.
(function() { }).call(myObject)
Thats an IIFE were the context gets myObject
, that allows you to write to the object easily with
this.someProp = someValue;
The IIFE also makes sure that your variables that you declared inside the function, e.g.:
var someValue = 1;
are not part of the global scope, so they are not polluting the global namespace.