Friday, October 17, 2025
HomeLanguagesJavascriptLodash _.not() Method

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'); 
  
var bool = _.not( true ); 
    
console.log("Opposite boolean value 'true' is : ", bool);
  
var bool = _.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'); 
  
var bool = _.not( 0 ); 
    
console.log("Opposite boolean value '0' is : ", bool);
  
var bool = _.not( 1 ); 
    
console.log("Opposite boolean value '1' is : ", bool);
  
var bool = _.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'); 
  
var bool = _.not( {} ); 
    
console.log("Opposite boolean value empty object is : ", bool);
  
var bool = _.not( {'G' : "neveropen"} ); 
    
console.log("Opposite boolean value object is : ", bool);
  
var bool = _.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
RELATED ARTICLES

Most Popular

Dominic
32361 POSTS0 COMMENTS
Milvus
88 POSTS0 COMMENTS
Nango Kala
6728 POSTS0 COMMENTS
Nicole Veronica
11892 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11954 POSTS0 COMMENTS
Shaida Kate Naidoo
6852 POSTS0 COMMENTS
Ted Musemwa
7113 POSTS0 COMMENTS
Thapelo Manthata
6805 POSTS0 COMMENTS
Umr Jansen
6801 POSTS0 COMMENTS