Last active
October 17, 2019 19:28
-
-
Save kikill95/def3ce033ae78453b6929346165f2dbc to your computer and use it in GitHub Desktop.
Short about OOP in JS
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() { | |
} | |
Animal.prototype.drink = function() { | |
console.info('drink!'); | |
}; | |
function Cat(shortName, longName) { | |
this.longName = longName; | |
var name = shortName; | |
this.shout = function() { | |
console.info(name); | |
}; | |
} | |
Cat.prototype.__proto__ = Animal.prototype; | |
var kitten1 = new Cat('Mursik', 'Mursik Van Milkovich'), | |
kitten2 = new Cat('Kesha', 'Kesha So Dvora'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment