Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8800769
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T00:40:37+00:00 2026-06-14T00:40:37+00:00

Possible Duplicate: What is the reason to use the ‘new’ keyword here? I am

  • 0

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…?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T00:40:39+00:00Added an answer on June 14, 2026 at 12:40 am

    Well, some browser’s franeworks used to mimic this by having A.prototype = new B(), but this is a bit hacky 🙂 One important gain of both ways is that monkey-patching parent class enabled descendants to use new/changed methods of the parent (which is not the case with A.prototype = $.extend({}, B.prototype) and similar hacks).

    As for the described approach, it definitely looks cleaner, so I would vote for “Yes”

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Is there any reason to use the 'auto' keyword in C /
Possible Duplicate: Can main function call itself in C++? I found this problem very
Possible Duplicate: Cannot use ‘this’ in member initializer? Any ideas why I get an
Possible Duplicate: Use of ‘prototype’ vs. ‘this’ in Javascript? Advantages of using prototype, vs
Possible Duplicate: Why shouldn’t I use PHP’s mail() function? In PHP, as long as
Possible Duplicate: What is System.Void? I have no practical reason for knowing this answer,
Possible Duplicate: When should I use a javascript framework library? All, I'm fairly new
Possible Duplicate: Is excessive use of this in C++ a code smell When should
Possible Duplicate: Is there any reason to use C instead of C++ for embedded
Possible Duplicate: Is there a good reason to use upper case for T-SQL keywords?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.