Lodash _.bitwiseAnd() 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 _.bitwiseAnd() method is used to return the result of using the Bitwise AND (&) operator on all the given arguments.
Syntax:
_.bitwiseAnd( val1, val2, ..., valn )
Parameters: This method takes a variable number of parameters and operates the Bitwise AND operator on them.
Return Value: This method returns the result of using the Bitwise AND operator on all the arguments.
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
var _ = require( 'lodash-contrib' );
var bA = _.bitwiseAnd( 1, 3 );
console.log( "The bitwiseAnd is :" , bA);
|
Output:
The bitwiseAnd is : 1
Example 2:
Javascript
var _ = require( 'lodash-contrib' );
var bA = _.bitwiseAnd( 1, 3, 4, 6 );
console.log( "The bitwiseAnd is :" , bA);
|
Output:
The bitwiseAnd is : 0
Example 3:
Javascript
var _ = require( 'lodash-contrib' );
var bA = _.bitwiseAnd( 1 );
console.log( "The bitwiseAnd is :" , bA);
|
Output:
The bitwiseAnd is : 1
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...