JavaScript Inheritance and Object Programming

Coding Tutorial, Chapter 5c

Inherit Box Data Properties

© 21 July, 2013, Martin Rinehart


Results

This class will not be testable until we add methods.

Code

Our init() passes its main job to Box.init(). Our toString() is also happy to let the base class fill in details.



The business of inheriting data properties is really just that simple, except that we don't really want to inherit all the base properties. In this example, we want our Buttons to use their own default background color.



Our init() will add that default value to the styles configuration object (being careful not to override a non-default value).

Feedback: Martin Rinehart at gmail dot com.

# # #