javascript-site

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:

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

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

 

Leave a Reply

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