JavaScript Inheritance and Object Programming

Coding Tutorial, Chapter 4a

Composition: Create a Borders Class

© 21 July, 2013, Martin Rinehart


A test is noted below. Otherwise, we fixed up our box from the last chapter to promise that it would support borders, too. It doesn't yet, but we'll get there.


We begin with a class skeleton with three do-nothing functions. (Our classes are written in alphabetical order, after the library functions. Borders comes before Box.)

Second, "params" becomes the actual parameters for the constructor (used in three places).

Third, our init() and toString() methods are asked to do a little real work. This lets us add a quick test, too.

Feedback: Martin Rinehart at gmail dot com.

# # #