super question

# Kris Zyp (18 years ago)

I was wondering if the super keyword causes base limiting only in classes, or in delegate chains as well. For example: function MyObj() { } MyObj.prototype.formatValue = function() { return "value: " + this.value }; var myObj = new MyObj; myObj.value = 10; myObj.formatValue = function() { return "The value is: " + super.formatValue(); }

If I called myObj.formatValue() would it go up the delegate chain to call a super formatValue? Would calling myObj.formatValue() return "The value is: value: 10" (as it would seem logical to me that it would)? Or does super only apply to super/sub classes? Thanks, Kris

# Jeff Dyer (18 years ago)

Super expressions limit references to names in the base class only, not the prototype. To do what you want you¹ll need to use a reference to Œconstructor.prototype.formatValue()¹.