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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T09:32:38+00:00 2026-05-29T09:32:38+00:00

is there a difference accessing javascript arguments via the default ‘arguments’ and using an

  • 0

is there a difference accessing javascript arguments via the default ‘arguments’ and using an explicit object such as ‘options’?

are these two similar apart from that one accesses the array arguments and the other accesses the object options?

$.fn.myFn = function(){
  if arguments[0]//....
}

and

$.fn.myFn = function(options){
  if options.value //....
}
  • 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-29T09:32:39+00:00Added an answer on May 29, 2026 at 9:32 am

    Yes, they’re similar, but they’re different as well. I wouldn’t use arguments for anything that doesn’t truly need to handle variable numbers of arguments; I’d use declared arguments and/or an options object. (Also note that on most JavaScript engines, using the arguments pseudo-array [it’s not really an array] incurs a runtime speed penalty compared with using declared arguments, or even an options object. See “side note” below, though of course you have to call the function a lot for that overhead to matter in the real world.)

    Using declared arguments for functions that accept only a couple of arguments usually makes sense, e.g.:

    x = parseInt(str, 10);
    

    If parseInt used an options-style object, you’d have to write that as:

    x = parseInt({string: str, radix: 10}); // Note: parseInt doesn't actually work this way
    

    …or similar, which is more typing on every call. So that’s a downside.

    But when you get into lots of arguments, and particularly lots of optional arguments, using the options pattern where you pass in an object instead of discrete arguments can have real payoffs. Consider the jQuery ajax function. It has ~32 options you can pass to it, nearly all of them optional. Just as you probably wouldn’t want to code every parseInt as above, you probably wouldn’t want to code every ajax call like this:

    $.ajax(
        "/path/to/resource",
        function(data) {
        },
        undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined,
        undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined,
        undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined,
        undefined, undefined, undefined, undefined, undefined, undefined
    );
    

    …either. 🙂

    One rule of thumb I’ve heard for discrete arguments vs. options-style objects is when you get to four arguments, people are going to start getting lost. You’ll want to draw your own line, of course.


    Side note: More about arguments being slower than declared args, try this test. Now of course, call overhead doesn’t matter most of the time, so most of the time this doesn’t matter. But for those times it does, here are the results from me and others:

    enter image description here

    As you can see, using declared arguments is the fastest by far on pretty much all engines. I even threw in something comparing arguments to passing in an array, for those times you really need a variable number of arguments (answer: you’re better off with the array).

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

Sidebar

Related Questions

When accessing values from an SqlDataReader is there a performance difference between these two:
Using the following union typedef, is there a difference in speed between accessing MyPacket.Byte.LB
Is there a difference between these two scenarios: (1) Accessing a property on a
Is there a difference (performance, overhead) between these two ways of merging data sets?
Is there a difference between generating multiple numbers using a single random number generator
There are three different syntax styles for accessing properties of an object: myProp =
all! I'm having some issues accessing an XML node's properties using Javascript. The XML
Is there any difference between accessing a property that has a backing field private
Is there difference in behavior between a constructor call and a procedure call in
Is there any difference between int on_exit(void (*function)(int , void *), void *arg); and

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.