JSFiddle - React, Tailwind, and code Playground
by demee
JavaScript
function Button() {
this.text = "Press Me";
}
function ToggleButton(toggle) {
this.toggle = toggle || "off";
}
ToggleButton.prototype = new Button;
ToggleButton.prototype.toggle = function() {
if (this.toggle === "on") {
this.toggle = "off";
} else {
this.toggle = "on";
}
}
var toggleButton = new ToggleButton("off");
alert(toggleButton.text);