mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-07 10:07:48 +00:00
short circuit isEmpty for null/undefined
This commit is contained in:
@@ -761,6 +761,7 @@
|
|||||||
// Is a given array, string, or object empty?
|
// Is a given array, string, or object empty?
|
||||||
// An "empty" object has no enumerable own-properties.
|
// An "empty" object has no enumerable own-properties.
|
||||||
_.isEmpty = function(obj) {
|
_.isEmpty = function(obj) {
|
||||||
|
if (obj == null) return true;
|
||||||
if (_.isArray(obj) || _.isString(obj)) return obj.length === 0;
|
if (_.isArray(obj) || _.isString(obj)) return obj.length === 0;
|
||||||
for (var key in obj) if (_.has(obj, key)) return false;
|
for (var key in obj) if (_.has(obj, key)) return false;
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user