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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T23:51:39+00:00 2026-06-02T23:51:39+00:00

var someObj = function() { } var p = new someObj(); alert(someObj.prototype); // This

  • 0
var someObj = function() { }
var p = new someObj();

alert(someObj.prototype);   // This works
alert(p.prototype);         // UNDEFINED, but why?

someObj.prototype.model= "Nissan";
alert(p.model);             // This works! I understand the dynamic nature of prototypes, but doesn't that mean that p.prototype === someObj.prototype?

Why is this so? Since “p” is an instance of “someObj”, why is the prototype undefined? I mean, when I add a property to “someObj” prototype, it is accessible to “p”, so why is the prototype not accessible?

  • 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-02T23:51:41+00:00Added an answer on June 2, 2026 at 11:51 pm

    The important thing here is that the prototype property of function objects is not the prototype of an object. It’s the object that will be assigned as the prototype of an object you create via new someObj. Prior to ES5, you can’t directly access the prototype of an object; as of ES5, you can, via Object.getPrototypeOf.

    Re

    alert(p.prototype); // UNDEFINED, but why?

    The reason is that the p object doesn’t have a property called “prototype”. It has an underlying prototype, but that’s not how you access it.

    All function objects have a property called prototype so that if they’re used as constructor functions, we can define what the properties of the underlying prototype of the objects created by those constructors will be. This may help:

    function Foo() {
    }
    Foo.prototype.answer = 42;
    
    console.log(Foo.prototype.answer); // "42"
    var f = new Foo();
    console.log(f.answer); // "42"
    

    That last line works like this:

    1. Get the f object.
    2. Does f have its own property called “answer”?
    3. No, does f have a prototype?
    4. Yes, does the prototype have its own property called “answer”?
    5. Yes, return the value of that property.

    You’ve mentioned Object.create in the title of your question. It’s important to understand that Object.create is quite separate from constructor functions. It was added to the language so that if you preferred not to use constructor functions, you didn’t have to, but could still set the prototype of an object — directly, when you create that object.

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

Sidebar

Related Questions

var conversations = new Array(); jQuery('.CChatWindow').each(function(){ if (jQuery(this).is(:visible) && jQuery(this).attr(data-conversationid) != 0) { alert(jQuery(this).attr(data-conversationid));
var h=0; var w=0; $(.extend).hover(function() { //alert(h); $(this).css({'z-index' : '999' }); $(this).addClass(hover).filter(:not(:animated)).stop() .animate({ marginTop:
var chart; var d = new Array(); function click() { d = document.getElementById('graph:hi').value; alert(d);
I have an object like this: var someObj = Class.create ({ initialize: function(objName){ this.objName
say I create someObj like this var someObj = function(){ var self = this;
var UsersMenu = function(){ this.returnUsers = []; this.retrieve = function(posts){ var temp = [];
var plugin = { Init: function() { this.UpdateUI(); if (this.Status() == 1) { ...
var MyObj = function(h,w){ this.height = h; this.width = w; } I would like
I'm trying to remove some eventlistener like this: var callback = function () {
The situation is somewhat like- var someVar = some_other_function(); someObj.addEventListener(click, function(){ some_function(someVar); }, false);

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.