Possible Duplicate:
What is the reason to use the ‘new’ keyword here?
I am studying Mongoose (what a beautiful piece of software...) and am seeing this:
function Model (doc, fields, skipId) {
Document.call(this, doc, fields, skipId);
};
/*!
* Inherits from Document.
*/
Model.prototype.__proto__ = Document.prototype;
Wow, that's the easiest way to set inheritance I've ever seen. I know it cannot be done with browsers, but server side... it looks like a winner:
- the derived class calls the constructor of the parent class
- The prototype object of the derived class is set so that proto points to the parent's class prototype.
And that's it!
Is this possibly the cleanest, easiest way to implement inheritance on the server's side? I am asking because I am in love with it, and am wondering if I am missing some limitations/problems...?