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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:26:30+00:00 2026-05-26T00:26:30+00:00

I want to understand the following behaviour because the explanation on this site javascript

  • 0

I want to understand the following behaviour because the explanation on this site javascript garden is not enough for me.

It would be much appreciated if you could give me a clear explanation about
the questions which are in the inline comments.

Here the example:

function Foo() {}

Foo.prototype.method = function(a, b, c) {
    console.log(this, a, b, c);
};

Foo.method = function() {
    Function.call.apply(Foo.prototype.method, arguments);
};


Foo.prototype.method(1,2,3) // Foo { method=function()} 1 2 3 //this output is obvious
Foo.method(1,2,3)  // Number {} 2 3 undefined // I want understand why the first argument is a number and the last one is undefined
  • 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-26T00:26:31+00:00Added an answer on May 26, 2026 at 12:26 am
    Function.call.apply(Foo.prototype.method, arguments);
    

    is the same as

    Foo.prototype.method.call(arguments[0], arguments[1], arguments[2], ...);
    

    which, in your case, is the same as:

    Foo.prototype.method.call(1, 2, 3);
    

    This means, inside Foo.prototype.method, this will refer to 1, but as this always has to reference an object (in non-strict environment), 1 is converted to a Number object.

    The last value is undefined because you are effectively only passing 2 and 3 (two arguments) to the method (instead of three).

    So in the end, the code is doing something similar to this:

    var obj = new Number(1);
    obj.method = Foo.prototype.method;
    obj.method(2,3);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Not that I would ever need to do this, but I want to understand
This is probably an easy question, but I want to understand better how Apache
I experience the following apparently undocumented issue, and I want to understand if I
I tried following this http://net.tutsplus.com/tutorials/javascript-ajax/an-introduction-to-the-raphael-js-library/ tutorial, but it does not work exactly with Raphael
I want to understand the following pattern, step by step. /\p{L}/u /u is a
I'm beginning to use DotNetOpenAuth and want to understand what the following members of
I want to understand if the following coding practice is good or bad practice.
The following screenshow is taken from IBM Heap Analyzer. I want to understand the
I m trying to understand what the following does. ^([^=]+)(?:(?:\\=)(.+))?$ Any ideas? This is
I just want to understand the following scenario. Where I am implementing a <TabControl>

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.