title: Javascript call prototype function from function inside constructor
body: <p>I searched for this issue for quite a long time. Din't find any answer to satisfy my question. What I am trying is:</p>
  
  <pre><code>function myClass() {
      function privateFunction () {
          publicFunction();    //Error
      }
  }
  
  myClass.prototype.publicFunction = function() {
      this.variable = 1;
  }
  myClass.prototype.publicFunction2= function() {
      return this.variable;
  }
  </code></pre>
  
  <p>This is giving me error. I am not getting what the real problem is:</p>
  
  <p>What I tried:</p>
  
  <pre><code>this.publicFunction();
  </code></pre>
  
  <p>Then:</p>
  
  <pre><code>myClass.publicFunction();
  </code></pre>
  
  <p>Then:</p>
  
  <pre><code>myClass.prototype.publicFunction();
  </code></pre>
  
  <p>This works but it overrides for each object. Acts as if it is static across different JS objects.</p>