Skip to content
Related Articles

Related Articles

Lodash _.bitwiseNot() Method
  • Last Updated : 29 Sep, 2020

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

filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


Output:

The bitwiseNot is : -2

Example 2:

Javascript

filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


Output:

The bitwiseNot is : -11

Example 3:

Javascript

filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


Output:

The bitwiseNot is : -101

full-stack-img

My Personal Notes arrow_drop_up
Recommended Articles
Page :