title: Add method with parameters to javascript object
body: <p>I am currently in process of porting one of my java applet games to javascript+html5. I have never done object oriented javascript before and this prototype based OO stuff is confusing me a lot.</p>
  
  <p>I tried to do a straightforward port from java but am having trouble doing two things:</p>
  
  <p>1) How do I run a function inside a constructor?<br>
  2) How do I add a method that has a parameter?</p>
  
  <p>Heres some example code:</p>
  
  <pre><code>function User()
  {
      setupStats();// I wanted to put some of the variable initializations into
      // a separate function for code modularity reasons.
  
      this.name='bob';
  
      //However that doesn't seem to work
      alert(this.gold); // gets Undefined
  
      alert(this.name); // gets bob. Phew at least this works
  
      //I also want to add a method with a parameter in it:
      this.draw=function(ctx){drawUser(ctx);};
  }
  
  function setupStats()
  {
      this.gold=2;
      this.exp=3;
      this.blah='blah';
      this.that='something else';
      this.superultraomg='insert some computation';
  }
  
  function drawUser(ctx)
  {
      ctx.drawImage(blah,blah,blah);
      alert(ctx); // Also gets undefined. Uh oh...
  
      alert(this.name); //Undefined? WHAT IS THIS I DONT EVEN...
  }
  </code></pre>
  
  <p>Please help guys!</p>