July 2011
Intermediate to advanced
276 pages
5h 11m
English
Be ready to watch for several things in this recipe. Firstly, note how the extended corvette methods can use this.parent. Secondly, note how the implemented corvette, the ZR1, can implement multiple classes.
Create a canvas to display some output.
<h1>Speed Indexes:</h1> <div id="mycanvas"></div>
Here we create a class to represent a car. This car does not have an engine until it goes through further steps of manufacturing, so if we ask what its speed is, the output is zero. Next, we create a class to represent a sporty engine, which has an arbitrary speed index of 10.
// create two classes from the base Class var Car = new Class({ showSpeed: function() { return ...