Forked from anonymous/Naive, very broken approach
Last active
August 29, 2015 14:19
-
-
Save rhocairn/a79f6c11d840a7f9c120 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 Animal(genus, species) { | |
var animal = Object.create(Animal.prototype); | |
animal.init(genus, species); | |
return animal; | |
} | |
Animal.prototype.init = function(genus, species) { | |
this.genus = genus; | |
this.species = species; | |
} | |
function Dog(species) { | |
var dog = Object.create(Dog.prototype); | |
dog.init('Canis', species); | |
return dog; | |
} | |
Dog.prototype = Object.create(Animal.prototype); |
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 Animal(genus, species) { | |
var animal = Object.create(Animal.prototype); | |
animal.genus = genus; | |
animal.species = species; | |
return animal; | |
} | |
function Dog(species) { | |
var dog = Animal.prototype.constructor.call(this, 'Canis', species); | |
dog.__proto__ = Object.create(Dog.prototype); | |
return dog; | |
} | |
Dog.prototype = Object.create(Animal.prototype); | |
Dog.prototype.constructor = Dog; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment