Skip to content

Instantly share code, notes, and snippets.

@ajcastro
Last active August 28, 2018 01:07
Show Gist options
  • Save ajcastro/287820e3e7fb3cde19c14b00bb706502 to your computer and use it in GitHub Desktop.
Save ajcastro/287820e3e7fb3cde19c14b00bb706502 to your computer and use it in GitHub Desktop.
// 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!';
}
@ajcastro
Copy link
Author

ajcastro commented Aug 28, 2018

I will use this, best solution so far..
https://www.npmjs.com/package/extends-js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment