JSFiddle - React, Tailwind, and code Playground
by jnfsmile
JavaScript
function Rectangle(width, height) {
this.height = height;
this.width = width;
}
Rectangle.prototype.area = function () {
return this.width * this.height;
};
var rect = new Rectangle(5, 10);
alert(rect.area());
function Square(side) {
return Rectangle.call(this, side, side);
}
Square.prototype = new Rectangle(); // yes, no arguments
Square.prototype.constructor = Square; // fix, otherwise it points to Rectangle
var sq = new Square(5);
alert(sq.area());
debugger;