Jump to content

The Science of Programming/SwayPresentations/Objects/ExtensionInheritance

From Wikibooks, open books for an open world

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

Next Previous Top