title: Extending prototypes in Javascript - good way?
body: <p>I want to validate that the approach I'm using is correct when it comes to extend a prototype - supposing "extend" is the right word.</p>
  
  <p>This topic gets a lot of clones. I'm still trying to properly understand this topic...</p>
  
  <p>The purpose is:
  - to write clean and good code.
  - to avoid using frameworks, if possible plain Javascript.
  - get advice on the clean frameworks that don't twist JS to obtain class-enabled behaviors.</p>
  
  <p>Here is the Parent prototype of my sandbox:</p>
  
  <pre><code>function Parent(){
  
  }
  
  Parent.prototype = {
  
      "init":function(){
  
          this.name = "anon";
      },
  
      "initWithParameters":function(parameters){
  
          this.name = parameters.name ? parameters.name : "anon";
      },
  
      "talk": function(){
  
          console.log('Parent is: ' + this.name);
      }
  }
  </code></pre>
  
  <p>Now the Child prototype - it adds a "position" property and redefines the behaviors:</p>
  
  <pre><code>function Child(){
  
      Parent.call(this);
  }
  
  
  Child.prototype = new Parent;
  Child.prototype.constructor = Child;
  
  Child.prototype.init = function(){
  
      Parent.prototype.call(this);
  
      this.setPosition(0, 0);
  }
  
  Child.prototype.initWithParameters = function(parameters){
  
      Parent.prototype.initWithParameters.call(this, parameters);
  
      if(!this.position){
  
          this.position = {x:0, y:0};
      }
  
      this.setPosition(parameters.pos.x, parameters.pos.y);
  }
  
  Child.prototype.setPosition = function(x, y){
  
      this.position.x = x;
      this.position.y = y;
  }
  
  Child.prototype.talk = function(){
  
      console.log('Child is: ' + this.name + ' and location is: ' + this.position.x + ', ' + this.position.y);
  }
  </code></pre>
  
  <p>Is this a good practice? Is there no shorthand to avoid writing "Child.prototype." when overriding a property (using a litteral maybe, like the Parent prototype is written).</p>
  
  <p>I know of J. Resig's Class/extend approach. But I'd rather use Javascript as the prototypical language it is, not make it work as a "class-like behaving class-less OO language".</p>
  
  <p>Thanks for your help :-)</p>