Underscore.js _.bitwiseNot() Method
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
var _ = require( 'underscore-contrib' );
var bN = _.bitwiseNot( 1 );
console.log( "The bitwiseNot is :" , bN);
|
Output:
The bitwiseNot is : -2
Example 2:
Javascript
var _ = require( 'underscore-contrib' );
var bN = _.bitwiseNot( 10 );
console.log( "The bitwiseNot is :" , bN);
|
Output:
The bitwiseNot is : -11
Example 3:
Javascript
var _ = require( 'underscore-contrib' );
var bN = _.bitwiseNot( 100 );
console.log( "The bitwiseNot is :" , bN);
|
Output:
The bitwiseNot is : -101
Last Updated :
07 Aug, 2020
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...