Skip to content

Instantly share code, notes, and snippets.

@AdarshKonchady
Created January 21, 2019 05:38
Show Gist options
  • Save AdarshKonchady/1e0e2f3d1af81e2f328513f2c882ef7b to your computer and use it in GitHub Desktop.
Save AdarshKonchady/1e0e2f3d1af81e2f328513f2c882ef7b to your computer and use it in GitHub Desktop.
inheritance1.js
function Animal() {
this.offspring = [];
}
function Dog() {
}
Dog.prototype = new Animal();
Dog.prototype.constructor = Dog;
var d1 = new Dog();
var d2 = new Dog();
var pup = new Dog();
d1.offspring.push(pup);
d2.offspring; // Does 'd2.offspring' have a pup in it?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment