How to useLodash _.isNull() Method in Javascript
Lodash _.isNull() method is used to find whether the value of the object is null. If the value is null then returns true otherwise it returns false.
Syntax:
_.isNull(value);
Example: In this example, we are checking whether the given value is null or not by the use of the _isNull() method.
Javascript
// Requiring the lodash library const _ = require( "lodash" ); // Use of _.isNull() // method let gfg = _.isNull( null ); let gfg1 = _.isNull(void 0); // Printing the output console.log(gfg); console.log(gfg1); |
Output:
true
false
How to check for null values in JavaScript ?
The null values show the non-appearance of any object value. It is usually set on purpose to indicate that a variable has been declared but not yet assigned any value. This contrasts null from the similar primitive value undefined, which is an unintentional absence of any object value. That is because a variable that has been declared but not assigned any value is undefined, not null.
Below are the approaches:
Table of Content
- By equality Operator (===)
- By Object.is() function
- By the typeof Operator
- Using Lodash _.isNull() Method
Contact Us