title: What is the correct way of calling an internal function using the module pattern in Javascript
body: <p>I am new to Javascript and am still getting my head round the various ways of creating objects i.e constructor+new, prototypal, functional &amp; parts.</p>
  
  <p>I have created what I think is an object factory using the module pattern and want to know what the correct method of calling an internal method would be. Is it via <strong><em>this</em></strong> or <strong><em>function name</em></strong>.</p>
  
  <p>Here is my module:</p>
  
  <pre><code>function chart() {
      function my() {
          // generate chart here, using `width` and `height`
      }
  
      my.sayHi = function(){
          console.log('hi');
          my.sayBye();
      };
  
      my.sayBye = function(){
          console.log('Bye');
      };
  
      return my;
      }
  
  var test = chart();
  test.sayHi();
  </code></pre>
  
  <p>You can see that the first function calls the second using <strong>my.sayBye()</strong> or is it better to use <strong>this.sayBye()</strong>. Both produce the same result and run without error.</p>