Skip to content

Instantly share code, notes, and snippets.

@dmi3y
Last active Aug 29, 2015
Embed
What would you like to do?
From Car to Honda
function Car (col) {
var color = col || 'white';
return {
paint: function (col) {
color = col;
},
getColor: function() {
return color;
}
};
}
function Honda (make) {
var honda = Car();
honda.make = make;
return honda;
}
hondaCRV = Honda('CR-V');
Car = {
color: 'white',
paint: function (col) {
this.color = col;
}
};
Honda = Object.create(Car);
Honda.model = function() {return this.make;};
hondaCRV = Object.create(Honda, {make: {value: 'CR-V'}});
function Car (color) {
this.color = color || 'white';
}
Car.prototype.paint = function (color) {
this.color = color;
};
function Honda (make) {
this.make = make;
}
Honda.prototype = new Car();
hondaCRV = new Honda('CR-V');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment