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

The Archive Base Latest Questions

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

My expectation from the following code would be that if I checked a.name ,

  • 0

My expectation from the following code would be that if I checked a.name, it would search the prototype and return it as it was declared. Can anyone pinpoint what it is that is preventing JS from acknowledging my prototype?

var obj = function(parent){
    return {
        prototype: parent
    }
};

var me = { name: 'keith' };

var a = new obj(me)
// => undefined

a.name
// => undefined

a.prototype.name
// => "keith"
  • 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-13T15:43:32+00:00Added an answer on June 13, 2026 at 3:43 pm

    A property named “prototype” is just a property, it does not point to the object from which the object inherits. Use Object.getPrototypeOf or the non-standard __proto__ property to get that.

    So what your function obj(me) returns is just an object with a property “prototype” which points to an object with a property “name” which points to the string keith. As your function returns an object, it makes no difference whether it is called with the new keyword or not.

    For inheritance, the “prototype” property of the constructor function [object] is of concern. Every object created by this constructor (which does not return an object) with the new keyword inherits from the object to which the “prototype” property of the constructor points. So you could do this:

    var Constructor = function() {
        console.log(this); // logs the currently created object
        // return nothing
    }
    Constructor.prototype = { name: 'keith' };
    
    var a = new Constructor(); // logs an empty object
    Object.getPrototypeOf(a) === Constructor.prototype; // true
    a.name; // "keith" - inherited
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

From everything I've seen around the net, it appears that the following code should
I have set PassengerPoolIdleTime to 0, with the expectation that this means I can
I am getting recarray from matplotlib.mlab.csv2rec function. My expectation was it would have 2
I don't know how make my application as auto start application.That is my expectation
The following code with VS2010 prints 0 , contrary to my expectations: #include <complex>
Consider the following code : #include <vector> #include <iostream> class a { public: int
I have the following Chars A C W B J M How can I
I would like start a long poll request from javascript which is fine and
I saw the following Python documentation which says that define variables in a Class
I have a pom.xml, which has following stuff declared Plugins - maven-surefire-plugin, groovy-maven-plugin and

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.