Thursday, May 14, 2026
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
32514 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
6892 POSTS0 COMMENTS
Nicole Veronica
12012 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12107 POSTS0 COMMENTS
Shaida Kate Naidoo
7016 POSTS0 COMMENTS
Ted Musemwa
7262 POSTS0 COMMENTS
Thapelo Manthata
6975 POSTS0 COMMENTS
Umr Jansen
6963 POSTS0 COMMENTS