Lodash is a JavaScript library that works on the top of underscore.js. Lodash helps in working with arrays, strings, objects, numbers, etc.
The _.bitwiseOr() method is used to return the result of using the Bitwise OR operator ( | ) on all the given arguments.
Syntax:
_.bitwiseOr( val1, val2, ..., valn );
Parameters: This method takes a variable number of parameters and operates the Bitwise OR operator on them.
Return Value: This method returns the result of using the Bitwise OR 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
// Defining lodash contrib variable var _ = require( 'lodash-contrib' ); // Using the _.bitwiseOr() method var bO = _.bitwiseOr( 1, 2, 3, 4, 5 ); console.log( "The bitwiseOr is :" , bO); |
Output:
The bitwiseOr is : 7
Example 2:
Javascript
// Defining lodash contrib variable var _ = require( 'lodash-contrib' ); // Using the _.bitwiseOr() method var bO = _.bitwiseOr( 1, 2, 1, 3, 3, 4, 7, 8, 5 ); console.log( "The bitwiseOr is :" , bO); |
Output:
The bitwiseOr is : 15
Example 3:
Javascript
// Defining lodash contrib variable var _ = require( 'lodash-contrib' ); // Using the _.bitwiseOr() method var bO = _.bitwiseOr( 5 ); console.log( "The bitwiseOr is :" , bO); |
Output:
The bitwiseOr is : 5