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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:19:13+00:00 2026-05-23T14:19:13+00:00

What is the difference between calling a function call(), and calling implicit constructor of

  • 0

What is the difference between calling a function call(), and calling implicit constructor of a inherited class?

Example1:

function DepthRectangle(w, h, d){
    Rectangle.call(this, w, h);
    this.depth = d;
}

Example2:

function DepthRectangle(w, h, d){
    this = new Rectangle(w, h);
    this.depth = d;
}

Constructor of Rectangle:

function Rectangle(w, h){
    this.width = w;
    this.height = h;
}
  • 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-05-23T14:19:14+00:00Added an answer on May 23, 2026 at 2:19 pm

    Well, your second example doesn’t work, because the this value is not assignable, it isn’t a valid left-hand side expression for assignments.

    But, suppose that you have:

    function DepthRectangle(w, h, d){
        var obj = new Rectangle(w, h);
        obj.depth = d;
        return obj;
    }
    

    In this case, the difference would be that the object returned by this function will inherit directly from Rectangle.prototype, and not from DepthRectangle.

    For example, with the above function:

    //...
    DepthRectangle.prototype.inherited = "foo";
    Rectangle.prototype.inherited = "bar";
    
    var obj = new DepthRectangle(1,2,3); // note: new is not really needed
    obj.inherited; // "bar", from Rectangle.prototype
    obj instanceof DepthRectangle; // false
    

    In your first example, using the call method will just execute the Rectangle function, but with the this value pointing to the object that was created on DepthRectangle, meaning that this object will in fact still inherit from DepthRectangle.prototype.

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

Sidebar

Related Questions

What is the difference between include() and calling a function in PHP? For example
Is there any difference between calling len([1,2,3]) or [1,2,3].__len__() ? If there is no
I'm wondering what's the actual difference between calling Thread.Sleep(1) and calling SwitchToThread (if we
In python, is there a difference between calling clear() and assigning {} to a
Given a BehaviorSubject, what is the practical difference between calling all of these different
delegate void DelegateTest(); DelegateTest delTest; Whats the difference between calling delTest.Invoke() and delTest() ?
What's the difference between clicking on: <a href /> vs. calling window.location.href = ...
Is there any difference between int on_exit(void (*function)(int , void *), void *arg); and
I noticed a difference when calling a function with empty parentheses, or without any
I am just wondering what is the difference between these two File1.js $(function() {

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.