improve #isEmpty implementation. add 2 tests

This commit is contained in:
Mike Frawley
2010-02-17 09:48:29 -06:00
parent 386ee8ade9
commit 130e860ecf
2 changed files with 5 additions and 1 deletions

View File

@@ -503,7 +503,9 @@
// Is a given array or object empty?
_.isEmpty = function(obj) {
return _.keys(obj).length == 0;
if (_.isArray(obj)) return obj.length===0;
for (var k in obj) return false;
return true;
};
// Is a given value a DOM element?