It might be some pattern which prevents this
to reach the global context (not in this case, since every variable is declared var
, but the author might wanted to use it as a general pattern to create objects).
var x = new (function () {
this.foo = "bar";
return {
// whatever
};
})();
console.log(foo); // Uncaught ReferenceError: foo is not defined
var x = (function () { // without new
this.foo = "bar";
return {
// whatever
};
})();
console.log(foo); // "bar"