Skip to content

Instantly share code, notes, and snippets.

@kikill95
Last active October 17, 2019 19:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kikill95/def3ce033ae78453b6929346165f2dbc to your computer and use it in GitHub Desktop.
Save kikill95/def3ce033ae78453b6929346165f2dbc to your computer and use it in GitHub Desktop.
Short about OOP in JS
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