A utility function that checks if a value is null
npx @tessl/cli install tessl/npm-lodash-isnull@3.0.0The lodash isNull function is a utility that checks if a given value is strictly equal to null. This function is part of the lodash Lang category and provides a reliable way to test for null values in JavaScript applications.
npm install lodashESM/ES6 Modules:
import _ from "lodash";CommonJS/Node.js:
const _ = require("lodash");import _ from "lodash";
// Check for null value
console.log(_.isNull(null)); // => true
console.log(_.isNull(undefined)); // => false
console.log(_.isNull(0)); // => false
console.log(_.isNull("")); // => false
console.log(_.isNull(false)); // => falseChecks if a value is null using strict equality comparison.
/**
* Checks if `value` is `null`.
*
* @static
* @memberOf _
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is `null`, else `false`.
*/
function isNull(value);Usage Examples:
// Basic null checking
_.isNull(null);
// => true
_.isNull(void 0); // undefined
// => false
// Testing with various falsy values
_.isNull(false);
// => false
_.isNull(0);
// => false
_.isNull("");
// => false
_.isNull(NaN);
// => false
// Testing with objects and arrays
_.isNull({});
// => false
_.isNull([]);
// => false
// Testing with functions
_.isNull(function() {});
// => falseImplementation Details:
===) comparison with nulltrue only for null valuesfalse for all other values including undefined, 0, false, "", and NaNCommon Use Cases:
Error Handling:
This function does not throw any errors. It safely handles all JavaScript value types including: