Add _.isNil function.

This commit is contained in:
xixilive
2015-08-20 13:20:48 +08:00
committed by John-David Dalton
parent b135431542
commit 5644a20eec
2 changed files with 85 additions and 2 deletions

View File

@@ -854,7 +854,7 @@
* `has`, `identity`, `includes`, `indexOf`, `inRange`, `isArguments`,
* `isArray`, `isBoolean`, `isDate`, `isElement`, `isEmpty`, `isEqual`,
* `isEqualWith`, `isError`, `isFinite` `isFunction`, `isMatch`, `isMatchWith`,
* `isNative`, `isNaN`, `isNull`, `isNumber`, `isObject`, `isPlainObject`,
* `isNative`, `isNaN`, `isNil`, `isNull`, `isNumber`, `isObject`, `isPlainObject`,
* `isRegExp`, `isString`, `isUndefined`, `isTypedArray`, `join`, `kebabCase`,
* `last`, `lastIndexOf`, `lt`, `lte`, `max`, `min`, `noConflict`, `noop`,
* `now`, `pad`, `padLeft`, `padRight`, `parseInt`, `pop`, `random`, `reduce`,
@@ -8273,6 +8273,35 @@
return value === null;
}
/**
* Checks if `value` is `null` or `undefined`.
*
* @static
* @memberOf _
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is `null` or `undefined`, else `false`.
* @example
*
* _.isNil(null);
* // => true
*
* _.isNil();
* // => true
*
* _.isNil(undefined);
* // => true
*
* _.isNil(NaN);
* // => false
*
* _.isNil(void 0);
* // => false
*/
function isNil(value) {
return value == null;
}
/**
* Checks if `value` is classified as a `Number` primitive or object.
*
@@ -11515,6 +11544,7 @@
lodash.isMatchWith = isMatchWith;
lodash.isNaN = isNaN;
lodash.isNative = isNative;
lodash.isNil = isNil;
lodash.isNull = isNull;
lodash.isNumber = isNumber;
lodash.isObject = isObject;