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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T02:37:35+00:00 2026-06-10T02:37:35+00:00

I have the following code: var A = function() {}; var a = new

  • 0

I have the following code:

var A = function() {};
var a = new A();
var b = new A();
A.prototype.member1 = 10;

A.prototype = {}
var c = new A();
console.log(a.member1);
console.log(a.constructor === b.constructor);
console.log(a.constructor === c.constructor);
console.log('---------');
console.log(c.member1);

It’s output is:

10
true
false
---------
undefined
undefined

The prototype of a and b has not changed and c had a new one. Am i right that this was caused by the fact that a.constructor is not equal to c.constructor and each of them had own prototype? Are there any other circs when constructors of two objects might not be equal?

Extra question: why there were printed two undefined strings? (Chromium)

  • 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-10T02:37:37+00:00Added an answer on June 10, 2026 at 2:37 am

    At the time you’re calling

    var a = new A();
    

    basically this assignment is done:

    a.__proto__ = A.prototype;
    

    Then you reassign the A.prototype to a new object, so c gets {} as its prototype.

    A.prototype = {};
    var c = new A();
    

    However, this doesn’t destroy the old A.prototype object – a.__proto__ is still pointing to it.

    Am i right that this was caused by the fact that a.constructor is not equal to c.constructor and each of them had own prototype?

    .constructor is basically just a convenience property. It has no effect on how instances behave.

    Extra question: why there were printed two undefined strings?

    Not in my console, they don’t! (Opera 12)

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

Sidebar

Related Questions

I have the following code: var words = new Object(); $(li.words).each(function(){ var thisId =
Say I have the following code: function One() {} One.prototype.x = undefined; function Two()
I have the following code: (function(){ var DS = (function(){ DS.prototype.queryDB = function() {
I have the following code: var ids = new Array(5); $(function(){ html5sql.process(sql, function(transaction, results,
I have the following code: var submitHandler = function ($link, $form, close) { var
I have the following code: var refreshId = setInterval(function() { $(#footad).html('myjshere'); }, 15500); Where
I have the following code: function show(){ var a=document.getElementById('somediv').style.display; a=block; } The above code
I have the following code: $(document).ready(function() { var id = 'cbx'; var idPrefix =
given i have the following block of code (function(){ var mb = { abc:function(){
i have the following code which switches some fullscreen-background-images (fadeOut, fadeIn). setInterval(function() { var

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.