function test(){ var a = 8; var b = 15; this.method = function() { alert(a+b); } window.onresize = this.method; } var a = new test();