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

  • Home
  • SEARCH
  • 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 8766303
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T16:31:03+00:00 2026-06-13T16:31:03+00:00

I saw two different patterns and explanations. One from DailyJS and many others: Rectangle.prototype

  • 0

I saw two different patterns and explanations. One from DailyJS and many others:
Rectangle.prototype = new Shape();

and then there’s Crockford’s here which implies just
Rectangle.prototype = Shape;

Now theory-wise, why you need to run the ‘new’? it runs the constructor function, yes. it also assigns the Rectangle’s prototype the Shape’s prototype. but we should be able to do inheritance just with a simple assignment of the parent into the prototype.

I wondered if the reason is prototype chaining. it seems, that in case 1, it will create a prototype chain. Meaning, that the Rectangle prototype will have the Shape prototype.
In the second case, the Rectangle’s prototype will just have Shape’s methods – but not Shape’s prototype methods.

Is that right? many thanks for any thoughts.

  • 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-13T16:31:04+00:00Added an answer on June 13, 2026 at 4:31 pm

    Crockford which implies just Rectangle.prototype = Shape;

    I can’t really see that.

    Now theory-wise, why you need to run the ‘new’? it runs the constructor function, yes.

    Yet we actually don’t need (want) that, we only need the inheritance from Shape.prototype

    it also assigns the Rectangle’s prototype the Shape’s prototype.

    Not really. new Shape creates a new object which inherits from Shape.prototype, that’s what matters us. You’ve got that right.

    In the second case, the Rectangle’s prototype will just have Shape’s methods – but not Shape’s prototype methods.

    Yes, that’s correct. You should inherit from Shape.prototype – but via Object.create(Shape.prototype), not by creating an instance. See JavaScript inheritance: Object.create vs new or What is the reason [not] to use the ‘new’ keyword here?. This is what Crockford actually does – and even before Object.create was introduced by EcmaScript 5.1, he found a clever way to do that with his helper function

    function object(o) {
        function F() {}
        F.prototype = o;
        return new F();
    }
    

    which is now the common shim for Object.create in browsers that don’t support it natively.

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

Sidebar

Related Questions

In short: I want to generate two different source trees from the current one,
I saw that even by writing separate commands, we can combine two different types
I saw two diffrent way to pass integer in assmbler: the one by [eax],
i actually read a tutorial about servlets and i saw two different ways to
We store two objects in session. Somehow, one of the objects from another user
I've got an app that has two different background images. The one selected is
In this question i saw two different answers how to directly call functions written
Today I saw two different types of Javascript function declarations and I'd like to
I've been reading through a few tutorials about css, and I saw two different
I am working with AIMLbot.dll in c#. I saw two functions saveToBinaryFile and loadFromBinaryFile

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.