From 5c6abc4453f3bdf9470bd98ec79d7f22105f87e3 Mon Sep 17 00:00:00 2001 From: Brad Dunbar Date: Mon, 30 Jan 2012 10:15:04 -0500 Subject: [PATCH] short circuit `isEmpty` for null/undefined --- underscore.js | 1 + 1 file changed, 1 insertion(+) diff --git a/underscore.js b/underscore.js index a24750d19..c4e8c8a59 100644 --- a/underscore.js +++ b/underscore.js @@ -761,6 +761,7 @@ // Is a given array, string, or object empty? // An "empty" object has no enumerable own-properties. _.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;