super question
# Jeff Dyer (19 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()¹.
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()¹.
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
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 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.mozilla.org/pipermail/es-discuss/attachments/20070608/4cae1a42/attachment-0002.html