Open In App

Lodash _.bitwiseLeft() Method

Last Updated : 29 Sep, 2020
Improve
Improve
Like Article
Like
Save
Share
Report

Lodash is a JavaScript library that works on the top of underscore.js. Lodash helps in working with arrays, strings, objects, numbers, etc.

The _.bitwiseLeft() method is used to return the result of using the Bitwise Left operator (<<) on all the given arguments.

Syntax:

_.bitwiseLeft( val1, val2,..., valn )

Parameters: This method takes a variable number of parameters and operates the Bitwise Left operator on them.

Return Value: This method returns the result of using the Bitwise Left 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.

Example 1:

Javascript




// Adding lodash-contrib library 
var _ = require('lodash-contrib'); 
  
// Using the _.bitwiseLeft() method
var bL  = _.bitwiseLeft( 1, 3, 5, 7, 9 ); 
    
console.log("The bitwiseLeft is :", bL);


Output:

The bitwiseLeft is : 16777216

Example 2:

Javascript




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


Output:

The bitwiseLeft is : 32

Example 3:

Javascript




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


Output:

The bitwiseLeft is : 1


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads