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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T05:49:19+00:00 2026-06-09T05:49:19+00:00

Introduction We all know these silly arguments objects of JavaScript functions. But why object?

  • 0

Introduction

We all know these silly arguments objects of JavaScript functions.

But why object? Isn’t it an array?

No, it’s not and that’s why a lot people call it a failure in JavaScripts concept:

(function () {
    return arguments.slice(); // TypeError: arguments.slice is not a function
}());

Intention

Okay, that’s just an introduction to the real thing I’d like to ask, but before asking you need some more information:

While reading different code during the last days, I got quite scarry while seeing the following line of code in quite a lot places.

args = Array.prototype.slice(arguments);

So, what does it do, is simply “converting” the arguments object into an array with all of its prototypes and stuff.


My solution

What I thought of was the following: While JavaScript is all about prototyping, why don’t we extend the arguments object’s prototype itself? I checked some sites for existing scripts, but found nothing I was intended to find and finally got to write it myself:

(function () {
    var i, methods;

    arguments.constructor.prototype = Array.prototype;
    methods = ['concat', 'join', 'pop', 'push', 'reverse', 'shift', 'slice', 'sort', 'splice', 'toString', 'unshift'];

    for (i = 0; i < methods.length; i += 1) {
        if (arguments.constructor.prototype.hasOwnProperty(methods[i]) === false) {
            arguments.constructor.prototype[methods[i]] = Array.prototype[methods[i]];
        }
    }
}());

After compression it takes 260 byte only and extends the arguments object’s prototype by using Array.prototype.

So finally I can handle arguments objects just the same way as “real” arrays.


The question

After checking the most famous JavaScript frameworks I finished with the following: none uses such a construct and extends the arguments object’s prototype.

But why? Is there anything wrong with, I don’t think of right now?

  • 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-09T05:49:20+00:00Added an answer on June 9, 2026 at 5:49 am

    the arguments object is not a type, it is a generic Object. In order to extend it’s prototype, you would have to extend the prototype of Object, which is generally not a good idea.

    There is nothing wrong with converting arguments to an Array using Array.prototype.slice.

    Let’s say I was to extend the arguments prototype:

    arguments.constructor.prototype.foo = 'bar';
    

    The problem here is that arguments.constructor is not some Argument object, it’s just Object. Now if I try to do something that should work normally, it’s fubar’d:

    var someNewObject = {
        someProperty: 'someValue'
    };
    
    for (var item in someNewObject) {
        console.log(item);  // logs someProperty AND foo, not good
    }
    

    You can see this in action here.

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

Sidebar

Related Questions

I know questions like this have been asked numerous times, but not quite this
First off I'm not sure that's the proper title for this question but hopefully
Note: this introduction is about entity systems. But, even if you don't know what
Long introduction: Normally all data necessary for my web application are stored in session
I am after a all round installation and introduction to Glassfish. (ie Your boss
Introduction I have been so annoyed by applications that have a startup dialog which
Introduction: Now I know this question could be very broad and it would be
Introduction I'm relatively new to C++. I went through all the basic stuff and
I've been adding quite a bit of javascript to my pages lately, but have
I know that there are a lot of discussions already on SO about SOAP,

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.