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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:24:47+00:00 2026-05-26T12:24:47+00:00

Tell me if I’m wrong: A prototype is a normal object. When an object

  • 0

Tell me if I’m wrong:

A prototype is a normal object. When an object inherits a prototype, it does not just copy the properties of the prototype, the object stores a reference to the prototype.

In Firefox, I can do:

var food = {fruit:"apple"};
var more_food = {vegetable:"celery"};
food.__proto__ = more_food;
food.vegetable // celery
food.fruit // apple

I can use the __proto__ property to manually set the reference to the prototype object.

I can also use Object.create:

var food = {fruit:"apple"};
var more_food = {vegetable:"celery"};
food = Object.create(more_food);
food.vegetable // celery
food.fruit // undefined

What exactly is Object.create doing? Is the variable food assigned the reference to the prototype more_food, or is Object.create just returning a copy of the object more_food? If Object.create is just making a copy, then how does the prototype chain work if the variable food has no reference to more_food?

  • 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-26T12:24:48+00:00Added an answer on May 26, 2026 at 12:24 pm

    A prototype is a normal object. When an object inherits a prototype, it does not just copy the properties of the prototype, the object stores a reference to the prototype.

    You’re right, the prototype of an object, is just another object referenced through the prototype chain.

    The difference between your two snippets is that with __proto__ you are mutating the prototype of food. In your second example, you are just assigning a new object that inherits from more_food, that’s why food.fruit is resolved to undefined, because your original food object is lost by that assignment.

    What exactly is Object.create doing?

    Object.create builds a new object that inherits from the object passed as its first argument (it can be only either an object or null).

    Is the variable food assigned the reference to the prototype more_food, or is Object.create just returning a copy of the object more_food?

    Your food variable will hold a new object, which inherits from more_food, there’s no any copying in this operation.

    For example:

    var food = {fruit:"apple"};
    var more_food = Object.create(food, {
      vegetable: { value: "celery" }
    });
    
    more_food.fruit;     // "apple"
    more_food.vegetable; // "celery"
    

    In the above example, more_food inherits from food, in other words, food is the prototype of more_food, this prototypical reference is stored in an internal property called [[Prototype]]. The second argument of Object.create allows you to initialize properties on this new object.

    There’s no copying, it’s just plain delegation in the above example more_food.fruit is accesible through the prototype chain, the property lookup process is really simple, if a property is not found on an object, it’s looked up again (delegation!) on the object’s prototype, recursively, until an object whose prototype is null is found (like Object.prototype).

    So, more_food.fruit is an inherited property:

    more_food.hasOwnProperty('fruit'); // false, inherited
    'fruit' in more_food;              // true
    

    While vegetable is an own property of more_food:

    more_food.hasOwnProperty('vegetable'); // true
    

    The above example looks graphically like this:

    
      +---------------------+  [[Prototype]]  +---------------+
      | more_food           |+--------------->| food          |
      |---------------------|                 |---------------|
      | vegetable: "celery" |                 | fruit: "apple |
      +---------------------+                 +---------------+
    

    If Object.create is just making a copy, then how does the prototype chain work if the variable food has no reference to more_food?

    Object.create doesn’t create copies of objects, it just sets up the prototype of a new object at the time of its creation.

    Keep in mind that __proto__ is a non-standard feature and it’s going to be removed from implementations in the future, is already being listed as deprecated on the Mozilla Documentation, the main reason of this, and it’s also why the language may never have a way to mutate the prototype chain in the way __proto__ allows you is that it causes optimization and security problems, at the level of VM and JIT.

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

Sidebar

Related Questions

Tell me if I am wrong. I'm starting using quaternions. Using a rotation matrix
Please tell me what it does? $ ar -r libsldap.a
Please tell me what I am doing wrong. I am sending an email using
Please tell me whats wrong with this c# code.. public bool CloseCOMPort() { try
Tell me if my concept is wrong. I have 2 classes; Country and State
Tell me, how can I serialize/deserialize the fusion::vector object type? Thanks.
Please tell me what does the parameter (char* s) means?? Can it accept an
Tell me please, how to use getBulkUserInformationFor: method correctly? I have Could not authenticate
Please tell me what am I doing wrong here. What I want to do
Please tell me why this is not working. It was working but has inexplicably

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.