Arguments has a length, Object Literals do not?

I’m going to research on this and get back here. Basically, I’m wondering the following:

Why am I able to test inside of a function for arguments.length. But I can create an object literal and length is undefined? example:

[pastacode lang=”javascript” message=”” highlight=”” provider=”manual”]

function count(a,b) {
    console.log(arguments.length); // 2
}
count(1,2);

var obj = { a: 1, b : 2 };
console.log(obj.length); // undefined!

[/pastacode]

 

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.