Possible Duplicate:
is object empty?
So let's var someObject = { }; how can i detect that object hasnt any properties and methods?
Possible Duplicate:
is object empty?
So let's var someObject = { }; how can i detect that object hasnt any properties and methods?
function isEmpty(ob){
for(var i in ob){ return false; }
return true;
}
isEmpty({a:1}) // false
isEmpty({}) // true
object.prototype. Read here yuiblog.com/blog/2006/09/26/for-in-intrigueObject.prototype, you track it down, remove the offending code, then remove the offending developer.object.prototype extensions. There were even some quite famous libraries that did it (but I don't remember which ones were).... mmmmh an example in this bug report bugs.jquery.com/ticket/1529 and even older versions of the prototype libraryjson2 library (which was the cause of that bug) no longer extends Object.prototype as the original did. Same with prototypejs. They both removed the offending code. ;)