Created
November 4, 2013 23:26
-
-
Save j127/7311149 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Vehicle(manufacturer) { | |
this.manufacturer = manufacturer; | |
} | |
Vehicle.prototype.sayHello = function () { | |
alert('Hi there'); | |
}; | |
function Unicycle(manufacturer, spokes) { | |
Vehicle.call(this, manufacturer); | |
this.spokes = spokes; | |
} | |
Unicycle.prototype = Object.create(Vehicle.prototype); | |
Unicycle.prototype.constructor = Unicycle; | |
Unicycle.prototype.sayWater = function () { | |
alert('water'); | |
}; | |
var vehicle, unicycle; | |
v = new Vehicle('Tesla'); | |
u = new Unicycle('Bob', 30); | |
v.sayHello(); | |
u.sayHello(); | |
console.dir(v); | |
console.dir(u); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment