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 6230573
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T09:46:28+00:00 2026-05-24T09:46:28+00:00

I just got Javascript: The Good Parts by Douglas Crockford and I’m having some

  • 0

I just got Javascript: The Good Parts by Douglas Crockford and I’m having some difficulty understanding one of his examples regarding prototypes. The code in the book reads as follows:

if (typeof Object.create !== "function") {
    Object.create = function(o) {
        var F = function () {}
        F.prototype = o;
        return new F;
    };
}

I’m assuming that this code is used to target a function’s prototype. But why use such a complex approach? Why not just use variable.prototype? Crockford is the leading expert on Javascript so I’m sure there is a good reason for using this model. Can anyone help me understand it better? Any help would be appreciated.

  • 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-05-24T09:46:29+00:00Added an answer on May 24, 2026 at 9:46 am

    In ECMAScript 3, the new operator was the only standard way to set the [[Prototype]] internal property of an object, in this case, Crockford is just using a temporary constructor function F for that purpose.

    The o argument of that method, is set as the prototype property of the temporary constructor, and by invoking new F(); it builds a new empty object that inherits from F.prototype (see this question for more details about how new works).

    For example:

    var a = { a: 1 };
    var b = Object.create(a); // b inherits from a
    b.a; // 1
    

    In the above example, we can say that the b‘s internal [[Prototype]] property points to a.

    Object.getPrototypeOf(b) === a; // true
    

    In other words, b inherits from a.

    With the same example, we could use an empty constructor, e.g.:

     function F(){}
     F.prototype = a;
    
     var b = new F(); // b again inherits from a (F.prototype)
    

    Remember also that the prototype property of functions is different than the [[Prototype]] property that all objects have, the prototype property of functions is used when they are called with the new operator, to build a new object that inherits from that property.

    Also, be aware that now, the ECMAScript 5 Standard is being implemented, and this shim, doesn’t conform 100% with the spec, in fact, there are some features of the standard Object.create method that cannot be emulated on ES3.

    See also:

    • JavaScript prototype limited to functions?
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I remember reading in Douglas Crockford's Javascript the Good Parts book that there is
Has anyone got to some good code to zoom into an image using javascript?
I've just got the new Visual Studio 2010 Ultimate and Javascript Intellisense is not
Just asked how to check if an internet connection exists using javascript and got
I just got Delphi 2009 and have previously read some articles about modifications that
I just got a dedicated server from a hosting company, and for some reason,
I'm not too good on the whole JavaScript (I can do some basic validations)
Just saw some interesting code while doing a typo in coffee-script. I got the
Just got a request from my boss for an application I'm working on. Basically
Just got a question about generics, why doesn't this compile when using a generic

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.