how to use prototype to avoid copying of functions in javascript?
<p>I had written this code to simulate OOP inheritance and calling baseclass in javascript and it works:</p>

<pre><code>function Animal(name,age)
  {
    this._name = name; 
    this.setName = function (name) { this._name = name }
    this.getName = function() { return this._name }
  }

  function Cat(name,age)
  {
    Animal.call(this,name,age); // call baseclass constructor
    this.getName = function() { return Cat.prototype.getName.call(this)+", a cat" }
  }
  Cat.prototype = new Animal(); // will create the baseclass structure

  /// *****  actual execution  *****
  var puss = new Cat("Puss",3);
  var cheshire = new Cat("Cheshire",10);
  // do some actions
  console.log ( puss.getName() );
  // change cat's name
  puss.setName("Puss in boots");
  alert ( "new name --&gt;"+puss.getName() );
</code></pre>

<p>problem is that, for each instance of "new Cat()" the "getName" and "setName" functions are replicated. 
I have read a lot of articles on prototyping but none addressed the issue of calling the baseclass function.</p>
