Thursday, January 9, 2025
Google search engine
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

Recent Comments