title: Can someone please tell me what this javascript code is doing
body: <p>This code comes from jquery.validate.js. I think it is a self-executing function but I am having a hard time parsing the syntax with respect to the second function declaration. Is function($) {} the parameter to the first function, ie the factory?</p>
  
  <pre><code>(function (factory) {
      alert("In jquery.validate.js factory");
      if ( typeof define === "function" &amp;&amp; define.amd ) {
          define( ["jquery"], factory );
      } else {
          factory( jQuery );
      }
  }(function ($) {
  ... //body of function
  });
  </code></pre>