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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T06:31:07+00:00 2026-06-12T06:31:07+00:00

In JavaScript, every function’s prototype object has a non-enumerable property constructor which points to

  • 0

In JavaScript, every function’s prototype object has a non-enumerable property constructor which points to the function (EcmaScript §13.2). It is not used in any native functionality (e.g. instanceof checks only the prototype chain), however we are encouraged to adjust it when overwriting the prototype property of a function for inheritance:

SubClass.prototype = Object.create(SuperClass.prototype, {
    constructor: {value:SubClass, writable:true, configurable:true}
});

But, do we (including me) do that only for clarity and neatness? Are there any real-world use cases that rely on 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-12T06:31:08+00:00Added an answer on June 12, 2026 at 6:31 am

    I can’t really see why the constructor property is what it is in JS. I occasionally find myself using it to get to the prototypes of objects (like the Event object) in IE < 9. However I do think it’s there to allow some ppl to mimic classical OO programming constructs:

    function Foo()
    {
        this.name = 'Foo';
    }
    function Bar()
    {
        this.name = 'Bar';
    }
    function Foobar(){};
    Foo.prototype = new Foobar;
    Foo.prototype.constructor = Foo;
    Bar.prototype = new Foobar;
    Bar.prototype.constructor = Bar;
    var foo = new Foo();
    var bar = new Bar();
    //so far the set-up
    function pseudoOverload(obj)
    {
        if (!(obj instanceof Foobar))
        {
            throw new Error 'I only take subclasses of Foobar';
        }
        if (obj.constructor.name === 'Foo')
        {
            return new obj.constructor;//reference to constructor is quite handy
        }
        //do stuff with Bar instance
    }
    

    So AFAIK, the “advantages” of the constructor property are:

    • instantiating new objects from instance easily
    • being able to group your objects as being subclasses of a certain class, but still being able to check what particular type of subclass you’re dealing with.
    • As you say: being tidy.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

It is often said that every Javascript object has a prototype property, but I
Javascript has a poorly constructed but convenient arguments variable inside every function, such that
I know that the prototype property of JavaScript function objects is copied to the
I have a javascript function that runs every 3 seconds, is there any way
I have written a javascript function that uses setInterval to manipulate a string every
I'm using a javascript function to submit my form. This works in every browser
I have the following: Javascript: $(.bg .thumb_wrapper).click(function() { $(.bg .thumb_wrapper).removeClass(active); $(this).addClass(active); }); So every
I have the following function in JavaScript every part of the if statement executes
I have a Javascript code that executes a function every time a button is
I want to code a function in javascript that every time I call it

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.