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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:00:21+00:00 2026-05-23T10:00:21+00:00

If the arguments is just an object with a length property, then why does

  • 0

If the arguments is just an object with a length property, then why does it seem to behave differently from other non-array objects with respect to, say, Array.prototype.slice.

For example, the following code first alerts “undefined”, and then alerts “foo”. Why do these differ?

(function(a){
  var myobj = {0 : "foo"};
  var myobjarray = Array.prototype.slice.call(myobj);
  var argumentsarray = Array.prototype.slice.call(arguments);
  alert(myobjarray.shift());
  alert(argumentsarray.shift());
})("foo");
  • 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-23T10:00:22+00:00Added an answer on May 23, 2026 at 10:00 am

    It works if your object has a length property.

    var myobj = { 0: "foo", 1: "bar", length: 2 };
    var myobjarray = [].slice.call(myobj);
    alert(myobjarray.shift());
    

    Most Array methods rely on the length property. If you try to execute an Array method on an object that doesn’t expose the expected interface, you’ll get unexpected results.

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

Sidebar

Related Questions

The arguments object in JavaScript is an odd wart—it acts just like an array
Why was the arguments.callee.caller property deprecated in JavaScript? It was added and then deprecated
Function.prototype.bind = function(){ var fn = this, args = Array.prototype.slice.call(arguments), object = args.shift(); return
Consider the method declaration: String.format(String, Object ...) The Object ... argument is just a
How can I declare a method with keyword arguments just like rails do. some
Basically i just want to do an arbitrary operation using given arguments of arbitrary
I have just, in my groggy morning state, reversed & confused the arguments to
Total noobie question here. I'm just learning Java, and studying passing arguments to functions.
The python docs say: Return the length (the number of items) of an object.
I just started to use the object oriented programming in Python. I wander if

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.