better ways to write javascript functions
<p>Recently, my friend and I are developing a website that contains many JavaScript functions to let user have better UX.</p>

<p>But we are discussing the best approach for writing the javascript.</p>

<p>my version</p>

<pre><code>var namespace = window.namespace || {};

(function(namespace, $){
    var namespace.modules1 = {};

    namespace.modules1.function1 = function(){
        // blah blah blah
    }

    var namespace.modules2 = {};

    namespace.modules2.function1 = function(){
        // blah blah blah
    }

})(namespace, jQuery); // since jQuery is heavy used in our script
</code></pre>

<p>To call it </p>

<pre><code>$('selector').bind('some event', function(){
    namespace.modules.function1();
}
</code></pre>

<p>and my friend version is
my version</p>

<pre><code>var namespace = window.namespace || {};

(function(namespace, $){
  namespace.modules1 = function(){
      var _this = this;
      this.function1 = function(){
        // blah blah blah
      }
   }

  namespace.modules2 = function(){
      var _this = this;
      this.function2 = function(){
        // blah blah blah
      }
   }

})(namespace, jQuery); // since jQuery is heavy used in our script
</code></pre>

<p>To call it </p>

<pre><code>var obj1 = new namespace.modules1();
$('selector').bind('some event', function(){
    obj1.function1();
}
</code></pre>

<p>Actually our both versions are work fine, what we are concerning in terms </p>

<ul>
<li>performance</li>
<li>maintainable </li>
<li>effectivity to use </li>
</ul>

<p>Anyone have some thoughts on this problem? Thank you. </p>
