3 ms·
I ended up using constructors to create instances of an object, and Object.create to enable inheritance when defining the object. function Person(name, bir
by jtfairbank 11y ago
I ended up using constructors to create instances of an object, and Object.create to enable inheritance when defining the object.
function Person(name, birthday, ...) {
...
}
Person.prototype = Object.create(Animal.prototype);
See these for more:
* http://outof.me/javascript-prototypal-inheritance-for-classical-developers/ http://outof.me/javascript-prototypal-inheritance-for-classi...
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Introduction_to_Object-Oriented_JavaScript#Inheritance https://developer.mozilla.org/en-US/docs/Web/JavaScript/Intr...
* http://stackoverflow.com/questions/8453887/why-is-it-necessary-to-set-the-prototype-constructor http://stackoverflow.com/questions/8453887/why-is-it-necessa...