Open In App

Underscore.js _.bitwiseNot() Method

Last Updated : 07 Aug, 2020
Comments
Improve
Suggest changes
Like Article
Like
Report

The _.bitwiseNot() method returns the result of using the ~ operator on the argument.

Syntax:

_.bitwiseNot( value );

Parameters: This method takes a value to operate ~ operator on it.

Return Value: This method returns the result of using the ~ operator on the argument.

Note: This will not work in normal JavaScript because it requires the underscore.js contrib library to be installed. Underscore.js contrib library can be installed using npm install underscore-contrib –save.

Example 1: 

JavaScript
// Defining underscore contrib variable
var _ = require('underscore-contrib'); 

var bN  = _.bitwiseNot( 1 );

console.log("The bitwiseNot is :", bN);

Output:

The bitwiseNot is : -2

Example 2:

JavaScript
// Defining underscore contrib variable
var _ = require('underscore-contrib'); 

var bN  = _.bitwiseNot( 10 );

console.log("The bitwiseNot is :", bN);

Output:

The bitwiseNot is : -11

Example 3: 

JavaScript
// Defining underscore contrib variable
var _ = require('underscore-contrib'); 

var bN  = _.bitwiseNot( 100 );

console.log("The bitwiseNot is :", bN);

Output:

The bitwiseNot is : -101

Next Article

Similar Reads