JSFiddle - React, Tailwind, and code Playground
by demee
JavaScript
var Button = (function(){
var Button = function(text){
this.text = text;
_setText = _setText.bind(this); //Function.prototype.bind (ES5)
}
Button.prototype = {
click: function(){
_setText("Clicked");
}
};
var _setText = function(text){
this.text = text;
};
return Button;
}());
var button = new Button("OK");
var button2 = new Button("NOT OK");
button.click();
button._setText(); //ERROR