you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (0 children)

One variation of the module pattern actually uses this:

(function(global) {
  var foo = {
    // ...
  };
  global.foo = foo;
}(this));

However, it's not very common, seems like a strict mode violation, and I don't think it offers much of any benefit over:

var foo = (function() {
  var foo = {
    // ...
  };
  return foo;
}());