this.method() and base.method() in JavaScript

Michael Schwarz on Wednesday, November 2, 2005

I looked around for the problem when you want to inherit from a JavaScript "class" with overriding a method, but I didn't find any solution. Today I tried this, which is working, but not very nice coding:

var mybox = Class.create(); mybox.prototype = { update: function() { this.div.innerText = new Date(); } }

var mybox2 = Class.create(); mybox2.prototype = (new mybox()).extend({ update: function() { this.base_update();     this.div.innerText += "jjj"; } });

As you can see in the mybox2 I can call the base update method using this.base_update(). Are there any other ideas on how to implement inheritance with overriding base methods, but don't losing them?