How to double a variable with bitwise shift left in JavaScript

1 Answer

0 votes
let num = 8;

num = num << 1;  // This will double the value of num

console.log(num);

 
 
/*
run:
 
16
 
*/

 



answered Mar 9, 2025 by avibootz

Related questions

1 answer 198 views
1 answer 188 views
1 answer 197 views
1 answer 184 views
1 answer 203 views
1 answer 194 views
1 answer 217 views
...