title: Why does the jQuery constructor map to jQuery.fn.init?
body: <p>The <code>jQuery</code> constructor sort of maps its functionality to another constructor, <code>jQuery.fn.init</code>: </p>
  
  <pre><code>jQuery = function( selector, context ) {
      return new jQuery.fn.init( selector, context, rootjQuery );
  },
  </code></pre>
  
  <p>I'm wondering why.</p>
  
  <p><a href="https://stackoverflow.com/questions/4754560/help-understanding-jquerys-jquery-fn-init-why-is-init-in-fn">This question is very similar, but even the answerer admits they didn't really answer the question as to <em>why</em></a></p>
  
  <p><a href="https://stackoverflow.com/questions/18782973/why-is-the-init-function-in-jquery-prototype-and-not-in-jquerys-closure?rq=1">This question is still unanswered</a></p>
  
  <p><strong>Is this just for organizational purposes?</strong> Rather than putting the init function inside the jQuery constructor definition, maybe the authors wanted to package it.</p>
  
  <p><strong>Is there any reason to have the <code>.init()</code> method on the prototype?</strong>  I don't think anyone ever uses <code>$('.something')...init()...</code></p>
  
  <p><strong><a href="https://stackoverflow.com/questions/18782973/why-is-the-init-function-in-jquery-prototype-and-not-in-jquerys-closure?rq=1">This question</a> shows that its not necessary to have <code>.init</code> on the prototype.</strong></p>
  
  <p>And I just found <a href="https://stackoverflow.com/questions/2477370/why-does-jquery-do-this-in-its-constructor-function-implementation">this question</a> in which Dan Herbert's answer suggests that it is simply for structure/readability purposes.</p>
  
  <p>In conclusion, <strong>can I confirm that this constructor/prototype mapping funny-business is kind of unnecessary?</strong>  It seems to me that the <code>jQuery.fn.init</code> functionality <em>could</em> go:</p>
  
  <ul>
  <li>Anywhere in the closure</li>
  <li>On the <code>jQuery</code> object (<code>jQuery.init</code> vs <code>jQuery.fn.init</code>)</li>
  <li>Or, what makes most sense to me: directly inside the <code>jQuery</code> function/constructor definition, replacing <code>new jQuery.fn.init</code> and avoiding the <code>jQuery.fn.init.prototype = jQuery.fn</code> mapping.</li>
  </ul>