Saturday, August 30, 2025
HomeLanguagesJavascriptLodash _.bitwiseNot() Method

Lodash _.bitwiseNot() Method

Lodash is a JavaScript library that works on the top of underscore.js. Lodash helps in working with arrays, strings, objects, numbers, etc.

The _.bitwiseNot() method is used to return the result of using the Bitwise NOT operator (~) on the given argument.

Syntax:

_.bitwiseNot( value );

Parameters: This method takes a single value as parameter as mentioned above and described below:

  • value: It is the value on which to apply the Bitwise NOT operator (~).

Return Value: This method returns the result of using the Bitwise NOT operator (~) on the argument.

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




// Adding lodash-contrib library 
var _ = require('lodash-contrib'); 
  
// Using the _.bitwiseNot() method
var bN  = _.bitwiseNot( 1 ); 
    
console.log("The bitwiseNot is :", bN);


Output:

The bitwiseNot is : -2

Example 2:

Javascript




// Adding lodash-contrib library 
var _ = require('lodash-contrib'); 
  
// Using the _.bitwiseNot() method
var bN  = _.bitwiseNot( 10 ); 
    
console.log("The bitwiseNot is :", bN);


Output:

The bitwiseNot is : -11

Example 3:

Javascript




// Adding lodash-contrib library 
var _ = require('lodash-contrib'); 
  
// Using the _.bitwiseNot() method
var bN  = _.bitwiseNot( 100 ); 
    
console.log("The bitwiseNot is :", bN);


Output:

The bitwiseNot is : -101
Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!
RELATED ARTICLES

Most Popular

Dominic
32249 POSTS0 COMMENTS
Milvus
81 POSTS0 COMMENTS
Nango Kala
6617 POSTS0 COMMENTS
Nicole Veronica
11792 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11838 POSTS0 COMMENTS
Shaida Kate Naidoo
6731 POSTS0 COMMENTS
Ted Musemwa
7013 POSTS0 COMMENTS
Thapelo Manthata
6689 POSTS0 COMMENTS
Umr Jansen
6701 POSTS0 COMMENTS