< The Science of Programming < SwayPresentations < Objects
Extension Inheritance
Extension inheritance: whereby the subclass adds features not found in the superclass.
function super(a)
{
var b = a + 1 * (a - 1);
this;
}
function sub()
{
var c = 3;
extends(super(c * c));
}
Now we make a sub object:
var s = sub(); inspect(s . b);
The output is:
s . b is 80
This article is issued from Wikibooks. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.