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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:14:50+00:00 2026-05-27T20:14:50+00:00

I was reading the jQuery documentation for plugin development and I ran across a

  • 0

I was reading the jQuery documentation for plugin development and I ran across a line of code I cannot wrap my head around.

  $.fn.tooltip = function( method ) {

if ( methods[method] ) {
  return methods[method].apply( this, Array.prototype.slice.call( arguments, 1 ));
} else if ( typeof method === 'object' || ! method ) {
  return methods.init.apply( this, arguments );
} else {
  $.error( 'Method ' +  method + ' does not exist on jQuery.tooltip' );
}    

The line in question:

return methods[method].apply(this, Array.prototype.slice.call(arguments,1));

I understand that all javascript objects inherit call() and apply() and I understand the differance between these two functions. What I don’t understand is the prototype on the Array. Array objects already have a slice() so why is the prototype needed here? Since call() takes two arguments which are a ‘this’ (context) and a list of arguments I don’t understand how the above call invocation works. Can someone help me understand this line?

Thanks

  • 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-27T20:14:50+00:00Added an answer on May 27, 2026 at 8:14 pm

    The arguments object inherits from Object.prototype. It may look like an array, but it isn’t. To perform array operations on it, the following line is necessary:

    Array.prototype.slice.call(arguments,1)
    

    The previous line copies the arguments “array”, and uses the slice(1) method on it.

    Array.prototype.slice(arguments, 1) is equivalent to:

    • Convert arguments to a true array (by setting this of Array.slice` to arguments)
    • Use the .slice(1) method to return an array which does not contain the first element.

    (Note that the arguments object is not modified during this process)

    Pseudo-code:

    var arguments = {1: "arg1", 2: "arg2", 3: "arg3", length: 3};
    var copy = convert_object_to_array(arguments); //This function does not exists
    // copy looks like: ["arg1", "arg2", "arg3"]
    copy.slice(1); //Returns ["arg2", "arg3"]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm reading some tutorials now about jQuery.. function creating,plugin creation etc. but these tutorials
I've been reading the documentation of a jQuery Validation Plugin and for some reason
I'm reading the documentation here: jQuery, Waypoints, plugin docs . And I'd like to
I have always used the mouseover event, but while reading the jQuery documentation I
I am trying to use the jQuery CSV plugin, as documented here: http://code.google.com/p/js-tables/wiki/CSV According
I'm reading the jQuery load documentation and it mentions that I can use load
I was reading the jQuery UI API for datepicker. The example code has something
I'm using jQuery in my web application. While reading its documentation I read about
I'm reading jQuery in Action, and on page 6 it says The $() function
I'm trying to use tagbar for reading code in jquery-1.7.1.js(renamed jquery.js) ,but it doesn't

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.