reddit comment
http://www.reddit.com/r/javascript/comments/1wa96w/avoiding_anonymous_javascript_functions/cf0bvmk
by path411
HTML
<input id="output" type="text"/>
<button id="button1">foo</button>
JavaScript
(function() {
function Program() {
this.ButtonValue = "foo";
this.Output = document.getElementById('output');
this.Button = document.getElementById('button1');
this.Button.addEventListener('click', this.onButtonClick.bind(this));
}
Program.prototype.onButtonClick = function(event) {
this.Output.value = this.ButtonValue;
}
function Main() {
var program = new Program();
}
Main();
})();