Joined October 2012
·
Posted to
How to check if JavaScript Object is empty
over 1 year
ago
Nice tip. Seems like the Underscore.js implementation -->
http://documentcloud.github.com/underscore/#isEmpty
Just that those guys are checking for Arrays and String in the same function like this:
_.isEmpty = function(obj) {
if (obj == null) return true;
if (_.isArray(obj) || _.isString(obj)) return obj.length === 0;
for (var key in obj) if (_.has(obj, key)) return false;
return true;
};
Achievements
130 Karma
7,260 Total ProTip Views

Python
Would you expect anything less? Have at least one original repo where Python is the dominant language
@datreee Cool buddy, any issues please ping me.