JSFiddle - React, Tailwind, and code Playground
HTML
<div id='myDiv' style="border: 1px, solid, black"> Click me!! </div>
JavaScript
var myProto = {
init: function (name, value) {
this.name = name;
this.value = value;
return this;
},
someHandler: function (e) {
// Normally I would use this instead of e.target...
e.target.innerHTML = this.name + this.value;
}
};
var myObject = Object.create(myProto).init('myName', 'myValue');
document.getElementById('myDiv').onclick = myObject.someHandler;