5 ms·
You don't count this as inheritance? Also, classes aren't required for OOP. function Parent() { // somestuff } function Child() { P
by jvm 14y ago
You don't count this as inheritance? Also, classes aren't required for OOP.
function Parent() {
// somestuff
}
function Child() {
Parent.call(this);
}
Child.prototype = new Parent();
Child.prototype.constructor = Child
- JonnieCache 14y agoI call that prototypical construction. The point is, it's hardly java.
- foodoo 14y agoNeither classes nor inheritance are necessary for OOP. A good read on this topic: http://wcook.blogspot.de/2012/07/proposal-for-simplified-modern.html http://wcook.blogspot.de/2012/07/proposal-for-simplified-mod... Btw, you can also do classes with JavaScript: http://mootools.net/docs/core/Class/Class http://mootools.net/docs/core/Class/Class JavaScript's prototype-based OOP is a superset of class-based OOP.