Menu
Does anyone know if there’s a way to check if an object has no elements?
[CODE]var myObject = new Object;
isEmpty(myObject);
somehow.
I know you could do this:
[CODE]function isEmpty(anObject) {
var count = 0;
for(var elem in anObject) {count++};
if(count > 0) return false;
else return true;
}
But that’s a trifle long-winded. I figured that if when you do for(x in object) it iterates the number of times for the number of elements in the object, there must be a simpler way to get this number….
Anyone have any idea?
Thanks, Robin.