JSFiddle - React, Tailwind, and code Playground
by manolenso
JavaScript
var Dog = function() {}; // defining Dog
Dog.prototype.bark = function() { console.log("wouf wouf"); };
var Doberman = function() {}; // defining Doberman
for(key in Dog.prototype) {
Doberman.prototype[key] = Dog.prototype[key];
}
Doberman.growl = function() { console.log("aouww"); };
var bobby = new Dog();
var rufus = new Doberman();
Dog.prototype.lick = function() { console.log("it tickles !") }; // adding a new method to the Dog's proto
bobby.lick(); // Dog instance can use this new method, prints "it tickles !"
rufus.lick(); // Doberman instance can't ! TypeError : Object [object] has no method 'tickle'