JSFiddle - React, Tailwind, and code Playground
by podgorniy
JavaScript
function bind (context, func) {
return function () {
return func.apply(context, arguments)
}
}
function Obj () {
this.fly = bind(this, function () {
// event handler
});
this.init();
}
Obj.prototype.fly = function () {
// this - объект
console.log('I am flying', this)
}
Obj.prototype.init = function () {
document.addEventListener('click', this.fly, false);
}
Obj.prototype.destroy = function () {
document.removeEventListener('click', this.fly, false);
}