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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:44:24+00:00 2026-05-27T04:44:24+00:00

Got a weird case where the javascript arguments object is being heavily relied on.

  • 0

Got a weird case where the javascript arguments object is being heavily relied on. I’ve got the problem ‘solved’ but was wondering if someone could explain to me some of the behavior that results from this code:

function whatweget(arg1,arg2,arg3) {
    while(arguments.length<3) { arguments[arguments.length++] = undefined; }
    console.log(arguments);
}
function argstest() {
    arguments[arguments.length++] = 3;
    console.log(arguments);
}
whatweget(1,2);
whatweget(1,2,3);
whatweget(1,2,3,4);
argstest(3);

Outputs in Chrome:

[1, 2, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined]
[1, 2, 3]
[1, 2, 3, 4]
[3, 3]

Inspecting the arguments object at the whatweget console.log shows it having 20 items, the first 3 are bolded while the last 17 are slightly faded. Inspecting arguments in the argstest console.log these ‘ghost’ parameters don’t show up. This is not a problem as subsequent scripts will be passed ‘arguments’ and use the ‘length’ parameter which is set properly, but was wondering if anyone had any insight into this behavior?

Oh, and btw, Firefox 8 is totally cool with this behavior. It does everything as expected, well, except that it doesn’t show the arguments object in the Watch inspector, though it will show it as an array when you hover your mouse over it. Bad Firefox, bad bad firefox.

  • 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-27T04:44:25+00:00Added an answer on May 27, 2026 at 4:44 am

    If you are testing in the developer console, I think it is a console display bug.

    If you do a for-in over the arguments object in order to enumerate all of its properties, you only get the 3 you would expect.

    function whatweget(arg1,arg2,arg3) {
        while(arguments.length<3) { arguments[arguments.length++] = undefined; }
        for( var n in arguments ) console.log(n, arguments[n]);
    }
    
    0 1
    1 2
    2 undefined
    

    Or if I return the arguments object, and test for properties using in, it shows the properties are not there.

    function whatweget(arg1,arg2,arg3) {
        while(arguments.length<3) { arguments[arguments.length++] = undefined; }
        return arguments;
    }
    
    var args = whatweget(1,2);
    
    console.log( '2' in args );  is true
    console.log( '5' in args );  is false
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i got a weird problem regarding egrep and pipe I tried to filter a
I've got this weird problem - I'm calling ChangeServiceConfig on a newly installed service
I am facing a weird problem. I have got a file called in which
I got this weird problem where System.Action cant be resolved when its not explicitly
I'm building my chrome extension and I've got weird problem. This is script I'm
I've got a somewhat weird case, where a for-loop is incredibly slow when I
I've got a very weird behavior, in my java (spring) application, I've a case
got a weird question for you based on some weird happenings on our site.
I got this weird error which mentions I should install VSTS 2008 SP1, during
I got some weird error with response.redirect() and the project wasn't building at all..

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.