diff --git a/underscore.js b/underscore.js index 21a45c0d9..ba2ee7600 100644 --- a/underscore.js +++ b/underscore.js @@ -309,7 +309,11 @@ // Return the number of elements in an object. _.size = function(obj) { - return _.toArray(obj).length; + if (_.isArray(obj)) { + return obj.length; + } else { + return _.keys(obj).length; + } }; // Array Functions