Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save j127/7311149 to your computer and use it in GitHub Desktop.
Save j127/7311149 to your computer and use it in GitHub Desktop.
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