есть код
function Shape () {
this.constructor.name = Shape;
}
Shape.prototype = {
getPerimeter: function () {
if ( this.constructor == Shape ) throw Error( "Forbidden" );
var p = 0;
for ( var i = 0; i < this.sides.length; i++) {
p += this.sides[i];
}
return p;
},
getSquare: function () {
if ( this.constructor == Shape ) throw Error( "Forbidden" );
},
getType: function () {
if ( this.constructor == Shape ) throw Error( "Forbidden" );
return name;
}
}
Shape.prototype.constructor = Shape; //иначе Object() !!!!
var Triangle;
(function () {
Triangle = function ( a, b, c ) {
this.sides = [ a, b, c ];
}
Triangle.prototype = new Shape();
Triangle.prototype.constructor = Triangle;
Triangle.prototype.getSquare = function () {
var p = this.getPerimeter()/2;
var S = Math.sqrt( p * ( p - this.sides[0] ) * ( p - this.sides[1] ) * ( p - this.sides[2] ) );
return Math.floor( S );
}
})();
var t = new Triangle ( 10, 15, 20 );
как мне получить тип обекта t и вывести его куданить ( скажем в алерт тот, не суть )