Checking if an implied object is empty
January 19th, 2009
An implied JavaScript object (e.g. var o = {};) will always be a truthy value. Since we have no index or length, there is no graceful way to check whether or not these variables have been populated. Here is a simple function to check for an implied object that has no data.
function isEmpty(obj) {
for (var o in obj) {
return false;
}
return true;
}
Recently Noughted