Lodash _.not() Method

The Lodash _.not() method returns a boolean value which is the opposite of the truthiness boolean value of the given value.
Syntax:
_.not( value );
Parameters: This method takes one parameter as mentioned above and described below:
- value: Given value for returning opposite boolean.
Return Value: This method returns a Boolean value.
Note: This will not work in normal JavaScript because it requires the lodash.js contrib library to be installed. Lodash.js contrib library can be installed using npm install lodash-contrib –save.
Example 1:
Javascript
| // Defining lodash contrib variable  var_ = require('lodash-contrib');   varbool = _.not( true);     console.log("Opposite boolean value 'true' is : ", bool);  varbool = _.not( false);     console.log("Opposite boolean value 'false' is : ", bool); | 
Output:
Opposite boolean value 'true' is : false Opposite boolean value 'false' is : true
Example 2:
Javascript
| // Defining lodash contrib variable  var_ = require('lodash-contrib');   varbool = _.not( 0 );     console.log("Opposite boolean value '0' is : ", bool);  varbool = _.not( 1 );     console.log("Opposite boolean value '1' is : ", bool);  varbool = _.not( 10 );     console.log("Opposite boolean value '10' is : ", bool); | 
Output:
Opposite boolean value '0' is : true Opposite boolean value '1' is : false Opposite boolean value '10' is : false
Example 3:
Javascript
| // Defining lodash contrib variable  var_ = require('lodash-contrib');   varbool = _.not( {} );     console.log("Opposite boolean value empty object is : ", bool);  varbool = _.not( {'G': "zambiatek"} );     console.log("Opposite boolean value object is : ", bool);  varbool = _.not( null);     console.log("Opposite boolean value 'null' is : ", bool); | 
Output:
Opposite boolean value empty object is : false Opposite boolean value object is : false Opposite boolean value 'null' is : true
 
				 
					


