Created
January 21, 2019 05:38
-
-
Save AdarshKonchady/1e0e2f3d1af81e2f328513f2c882ef7b to your computer and use it in GitHub Desktop.
inheritance1.js
This file contains hidden or 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() { | |
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