Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

For the pragmatics, a simpler and not so cluttered example of the constructor, illustrating what 'this' does and how you can pass 'this' by argument:

  function value()
  {
      this.v = 32;
  }

  function twice( n )
  {
      n.v += n.v;
  }

  number = new value();
  document.write( number.v + ' ' );

  twice( number );
  document.write( number.v );


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: