Last active
August 28, 2018 01:07
-
-
Save ajcastro/287820e3e7fb3cde19c14b00bb706502 to your computer and use it in GitHub Desktop.
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
// I will use this, best solution so far.. this is updated as of aug-28-2018 | |
// https://www.npmjs.com/package/extends-js | |
function $extends(child, parent) { | |
child.prototype = Object.create(parent.prototype); | |
child.prototype.constructor = child; | |
}; | |
function Animal(name, color) { | |
this.name = name; | |
this.color = color; | |
this.sound = ''; | |
} | |
Animal.prototype.makeSound = function () { | |
return this.sound; | |
}; | |
$extends(Dog, Animal); | |
function Dog(name, color) { | |
Animal.apply(this, arguments); | |
this.sound = 'aw aw!'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I will use this, best solution so far..
https://www.npmjs.com/package/extends-js