Skip to content

isEmpty

js
_.isEmpty(value)

检查 value 是否是空对象、集合、映射或集合。

¥Checks if value is an empty object, collection, map, or set.

如果对象没有自己的可枚举字符串键属性,则将其视为空。

¥Objects are considered empty if they have no own enumerable string keyed properties.

如果 length0,则类似数组的值(例如 arguments 对象、数组、缓冲区、字符串或类似 jQuery 的集合)将被视为空。同样,如果映射和集合的 size0,则它们被视为空。

¥Array-like values such as arguments objects, arrays, buffers, strings, or jQuery-like collections are considered empty if they have a length of 0. Similarly, maps and sets are considered empty if they have a size of 0.

新增于

¥Since

0.1.0

参数

¥Arguments

  1. value (*):要检查的值。

    ¥value ()*: The value to check.

返回

¥Returns

(布尔):如果 value 为空,则返回 true,否则返回 false

¥(boolean): Returns true if value is empty, else false.

示例

¥Example

js
_.isEmpty(null);
// => true

_.isEmpty(true);
// => true

_.isEmpty(1);
// => true

_.isEmpty([1, 2, 3]);
// => false

_.isEmpty({ 'a': 1 });
// => false

Lodash v4.17 中文网 - 粤ICP备13048890号