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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T15:46:34+00:00 2026-06-15T15:46:34+00:00

I cannot find anywhere in the JS spec where functions – when called with

  • 0

I cannot find anywhere in the JS spec where functions – when called with new should set the constructor property of their prototype to themselves.

Sure the spec says the Built-in constructors (Object, Array, String, &c) all set their prototype.constructor properties to themselves (i.e. Object.prototype.constructor = Object) BUT I can’t find anywhere that says this must/should happen for other constructors (seems it should be spelled out in the [[Construct]] section (13.2.2 [[Construct]]) yet it is not:

function F() {};
var obj = new F();
Object.getPrototypeOf(obj).constructor == F;  // non-standard??  I can't find where in spec

I ask because I see a lot of code ‘resetting’ the prototype.constructor property of a constructor ‘back’ to itself – yet this appears to be non-standard that this property points back to the constructor function in the first place?

function F() {};
F.prototype = new Parent();
F.prototype.constructor = F;  // 'reset' it cuz it changed! (according to spec it should never have been set?  Except in Object.prototype.

Can/should JS programmers rely on this non-standard(?) expectation that a constructor’s prototype.constructor property will point back to the constructor function itself if the prototype property is not set?

V8 certainly does this:

function F() {};
console.log(F.prototype.constructor === F); // true!  WHY???  not in spec?  Should be Object?

Hope that made vague sense – thanks!!
Mark

PS Due to their mutability I would only rely on instanceof instead of using the constructor property.

  • 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-15T15:46:35+00:00Added an answer on June 15, 2026 at 3:46 pm

    It is standard for all functions to have a .prototype property that points to an object with a .constructor property that points back to the function.

    13.2 Creating Function objects

    1) Create a new native ECMAScript object and let F be that object.

    …

    16) Let proto be the result of creating a new object as would be constructed by the expression new Object() where Object is the standard built-in constructor with that name.

    17) Call the [[DefineOwnProperty]] internal method of proto with arguments "constructor", Property Descriptor {[[Value]]: F, { [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true}, and false.

    18) Call the [[DefineOwnProperty]] internal method of F with arguments "prototype", Property Descriptor {[[Value]]: proto, { [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: false}, and false.

    So you can see F is the new function and proto is the prototype object. The proto gets a "constructor" property that points to F, and F gets a "prototype" property that points to the proto object

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

Sidebar

Related Questions

Simple question but cannot find answer anywhere. When using a MS Chart Control of
Ok this is a homework questions, but I cannot find the answer anywhere, not
I am having an issue which I cannot find documented anywhere, i see a
Ok this is very trivial question, but just cannot find answer anywhere. I know
Alright cannot find this anywhere and I was wondering how to grab the values
I cannot find anywhere how to add a button to the top-right corner of
I am getting a CloneNotSupportedException, but I cannot find anywhere in my code where
I cannot find anywhere how to create a stringtable in Builder C++ 2010. Do
Please look at this screenshot: https://i.stack.imgur.com/kJrrT.jpg I cannot find anywhere under Colors & Fonts
This may be a really stupid question, but I cannot find anything anywhere as

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.