Generic createHandlers() method.

by nfreitas

HTML

<button id=clickMe>Click Me</button>

JavaScript

var Person = function () {
    this.name = "My Name is Person";
    this.createHandlers();
};

Person.prototype.sayHello = function () {
    alert(this.name);
};

Person.prototype.createHandlers = function () {
    for (var prop in this) {
        if (typeof this[prop] === 'function') {
            this[prop +  'Handler'] = this[prop].bind(this);
        }
    }
};

var person = new Person(),
    btn = document.getElementById('clickMe');

btn.addEventListener('click', person.sayHelloHandler, false);