size enhancement as ternary and _.size(arr) test case

This commit is contained in:
Raymond May Jr
2012-03-20 09:31:50 -05:00
parent 5827e4a40a
commit 4c2a85f9c5
2 changed files with 2 additions and 5 deletions

View File

@@ -309,11 +309,7 @@
// Return the number of elements in an object.
_.size = function(obj) {
if (_.isArray(obj)) {
return obj.length;
}else{
return _.keys(obj).length;
}
return _.isArray(obj) ? obj.length : _.keys(obj).length;
};
// Array Functions