O'Reilly logo
  • Reza Etemadi thinks this is interesting:

    function Shape() {} 
    // augment prototype 
    Shape.prototype.name = 'Shape'; 
    Shape.prototype.toString = function () { 
      return this.name; 
    }; 
 
    function TwoDShape() {} 
    // take care of inheritance 
    TwoDShape.prototype = Shape.prototype; 
    TwoDShape.prototype.constructor = TwoDShape; 
    // augment prototype 
    TwoDShape.prototype.name = '2D shape'; 
 
    function Triangle(side, height) { 
      this.side = side; 
      this.height = height; 
    } 
 
    // take care of inheritance 
    Triangle.prototype = TwoDShape.prototype; 
    Triangle.prototype.constructor = Triangle; 
    // augment prototype 
    Triangle.prototype.name = 'Triangle'; 
...
            
        
			

From

Cover of Object-Oriented JavaScript - Third Edition

Note

proper way would be TwoDShape.prototype = Object.create(Shape.prototype); OR TwoDShape.prototype = new Shape();