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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T14:41:09+00:00 2026-06-12T14:41:09+00:00

I know you can have one javascript instantiated object inherit the prototype of another

  • 0

I know you can have one javascript instantiated object inherit the prototype of another constructor with constructer.prototype.__proto__ = otherConstructer.prototype, but can you use the call method like this to do the same thing?:

function constructor () {
  otherConstructor.call(this);
}
  • 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-12T14:41:11+00:00Added an answer on June 12, 2026 at 2:41 pm

    No, the prototype can’t be replaced except by referencing the object itself and directly replacing it with the __proto__ property, which doesn’t exist in all implementations. Look at this sample code:

    function B() {
        this.someValue = "BBB";
    }
    B.prototype.testfunc = function() {
        console.log("Called from B: someValue =" + this.someValue);
    }
    
    function A() {
      this.someValue = "AAA";
      return B.call(this);
    }
    A.prototype.testfunc = function() {
        console.log("Called from A: someValue =" + this.someValue);
    }
    
    var test = new A();
    test.testfunc();
    
    // Will output "Called from A: someValue =BBB"
    

    As you can see, the B constructor is correctly called and the object setup is from B and not A, but nevertheless the object’s prototype is still from A. You can, of course, replace individual functions:

    test.testfunc = B.prototype.testfunc;
    test.testfunc();
    
    // Will output "Called from A: someValue =BBB"
    

    If you want a great explanation of why this is so, check out the accepted answer to this question.

    Edit: There is no association with B.prototype when an A object is created. If you changed the code so that A.prototype.testfunc is not defined, then even though the A constructor calls B, nevertheless calling test.testfunc() will result in an undefined exception.

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

Sidebar

Related Questions

I know that ScrollView can have only one Child but in my case I
I know that you can't have a constructor in an interface, but here is
In Xcode 4.2, I know that one can use the storyboard segue to have
I have a query that I know can be done using a subselect, but
I know with OO Perl I can have objects and inheritance, but are interfaces
Using web forms I know that you can only have one ASP.NET form on
I don't know much about Javascript and Jquery, but I do have to use
I know I can have 1 parent element and 1 child element in my
i know i can have iframe in a html page, say parent.htm, and i
I want to know can we have a JPanel with a Layout other than

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.