title: Building a JavaScript library, why use an IIFE this way?
body: <p>I have noticed a lot of libraries use this style below to define their library. I also notice that the first self invoking function has something to do with Require.js or AMD systems, they always have factory as an argument, I will look more into Require.js, always been into Browserify.</p>
  
  <p>Why is the main code passed into the end of the first self invoking function inside parentheses, is this is a closure, or just considered an anonymous function, I will dig deeper into both. What are the benefits to this? It looks like inside the closure the author passes a <code>string</code>, <code>this</code>, and a <code>callback</code>. </p>
  
  <p>Will this give my library a clean safe way to globalize the main object in this example below <code>Please</code>?</p>
  
  <pre><code>(function( globalName, root, factory ) {
      if ( typeof define === 'function' &amp;&amp; define.amd ) {
          define( [], factory );
      }
      else if ( typeof exports === 'object' ) {
          module.exports = factory();
      }
      else{
          root[globalName] = factory();
      }
  }('Please', this, function(){
  </code></pre>
  
  <p>I am trying to dig really deep into JavaScript and create my own small MVC architecture, I don't want to hear I am silly or its been done before, I want to challenge myself and learn. </p>
  
  <p>If there are any great resources for creating a JavaScript library or even better an MVC library I would love to know.</p>