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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T20:22:06+00:00 2026-05-16T20:22:06+00:00

If I have a function as such: function doStuff(arg) { arguments[0] = 4 +

  • 0

If I have a function as such:

function doStuff(arg) {
   arguments[0] = "4" + arg;
   console.log(arg);
   console.log.apply(null, arguments);
}

Clearly doStuff("name") prints “4name” twice.

Do arg and arguments[0] point to the same thing? Can I use them interchangeably. Is javascript doing anything internally that I should be aware about and are there any gotchas?

I am aware that arguments deals with all arguments passed not just the named parameters. I only care about how it deals with the first (or nth) parameter.

[Edit]

I’m actually using this as

function name(arg) {
   arguments[1] = args;
   arguments[0] = "[INFO] " + args.callee + " arg: %o";
   console.log.apply(this, arguments);
}

and calling name(arguments) in a function itself. Interestingly args.callee prints out the function source code rather then the function name.

  • 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-16T20:22:07+00:00Added an answer on May 16, 2026 at 8:22 pm

    The arguments “array” exists in any function context and enumerates the arguments recieved by the current context call. Yes arguments[0] refers to the first argument given, so if you’ve labelled that as “name” it will be same thing.

    Arguments is powerful for dealing with undefined quantities of arguments (i.e. param lists), meta-programming, or even where you want to impose some heuristic to determine what arguments represent what kind of data (i.e. you don’t trust the implementers), but that is a rather limited use case to say the least.

    I would strongly advise you avoid relying on the arguments array for two reasons:

    1). Index position is not a very safe mechanism to rely on this data actually meaning what you think it is, nor is it a flexible mechanism for handling change.

    2). You are effectively destroying information if you drop named params. Although JS function signatures are nothing like as rigid as they are in other languages, it’s still critical information for anyone trying to understand what your function actually does. JS is a language where being expressive really really matters.

    That said arguments contains other interesting properties such as “callee” which will afford you some considerable power for doing things that can’t be accomplished otherwise. That’s worth investigating yourself (good starting point here).

    There is also the more serious problem that arguments itself is in a strange sort of semi-deprecated, semi-supported state, so where used it does need to be x-browser tested and noted for future consideration.

    There are no internal gotchas I’m aware of.

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

Sidebar

Related Questions

If I have a method such as: private function testMethod(param:string):void { // Get the
in PHP, I have something like function doStuff($in, $value) { $var = V_ .
So I have a function such as: public static function UnorderedList($items, $field, $view =
Say I have a function such as: public TProperty Foo<TClass, TProperty>(TClass instance, Expression<Func<TClass, TProperty>>
I have a function that gives me the following warning: [DCC Warning] filename.pas(6939): W1035
I have a function that gets x(a value) and xs(a list) and removes all
I have a function where I need to do something to a string. I
I have a function that takes, amongst others, a parameter declared as int privateCount
I have a function in a native DLL defined as follows: #include <string> void
I have a function, parseQuery, that parses a SQL query into an abstract representation

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.