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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:24:07+00:00 2026-06-13T08:24:07+00:00

Possible Duplicate: What’s the meaning to chain call and apply together? I found some

  • 0

Possible Duplicate:
What’s the meaning to chain call and apply together?

I found some codes like this:

function fun() {
    return Function.prototype.call.apply(Array.prototype.slice, arguments);
}

I know the call and apply in js,however I am confused when they come together.

Then I wonder if

Function.prototype.call.apply(Array.prototype.slice, arguments)

is the same as :

Array.prototype.slice.apply(arguments);

If not,what does the first line do?

  • 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-13T08:24:08+00:00Added an answer on June 13, 2026 at 8:24 am

    Alright, let’s tackle this problem via substitution. We start with:

    Function.prototype.call.apply(Array.prototype.slice, arguments);
    

    What we know:

    1. Function.prototype.call is a function.
    2. The this pointer of call points to Function.prototype.
    3. We use apply to change the this pointer of call to Array.prototype.slice.
    4. arguments is applied (not passed as a parameter) to call.

    Thus the above statement is equivalent to:

    Array.prototype.slice.call(arguments[0], arguments[1], ...);
    

    From this we see:

    1. Array.prototype.slice is a function.
    2. The this pointer of slice points to Array.prototype.
    3. We use call to change the this pointer of slice to arguments[0].
    4. arguments[1], ... are passed as parameters to slice.

    This is the same as:

    arguments[0].slice(arguments[1], ...);
    

    The advantage of this is that we’re creating a fast unbound wrapper for slice in a single line.

    Edit: A better way to create fast unbound wrappers is as follows (note that it may not work in some older browsers, but you don’t really need to worry about that now – you may always use a shim for browsers which don’t support bind):

    var slice = Function.prototype.call.bind(Array.prototype.slice);
    

    This is the same as:

    function slice() {
        return Function.prototype.call.apply(Array.prototype.slice, arguments);
    }
    

    How it works:

    1. Function.prototype.call is a function.
    2. The this pointer of call points to Function.prototype.
    3. We use bind to change the this pointer of call to Array.prototype.slice.
    4. bind returns a function whose arguments are applied to call.

    Bonus: If your style of programming is highly functional, like mine is, then you would find that is piece of code is very useful:

    var funct = Function.prototype;
    var obj = Object.prototype;
    var arr = Array.prototype;
    
    var bind = funct.bind;
    
    var unbind = bind.bind(bind);
    var call = unbind(funct.call);
    var apply = unbind(funct.apply);
    
    var classOf = call(obj.toString);
    var ownPropertyOf = call(obj.hasOwnProperty);
    var concatenate = call(arr.concat);
    var arrayFrom = call(arr.slice);
    
    1. Using this you may easily create unbound wrappers using either call or apply.
    2. You may use classOf to get the internal [[Class]] of a value.
    3. You may use ownPropertyOf inside for in loops.
    4. You may use concatenate to join arrays.
    5. You may use arrayFrom to create arrays.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Can main function call itself in C++? I found this problem very
Possible Duplicate: Meaning of tilde-greater-than (~>) in version requirement? I see something like this
Possible Duplicate: What is the meaning of the term “free function” in C++? I
Possible Duplicate: What does ‘unsigned temp:3’ means I just found this code in a
Possible Duplicate: what's the meaning of this piece of code? void (*signal(int sig, void
Possible Duplicate: javascript function vs. ( function() { … } ()); I'm seeing this
Possible Duplicate: What do parentheses surrounding a JavaScript object/function/class declaration mean? I have found
Possible Duplicate: What is the meaning of “$” sign in javascript This may be
Possible Duplicate: const CFoo &bar() const Which is the meaning of this line? virtual
Possible Duplicate: What does this mean? (function (x,y)){…}){a,b); in JavaScript I am a starter

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.