Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,933 questions

51,870 answers

573 users

How to use left shift (<<) operator in JavaScript

2 Answers

0 votes
const a = 1;         // 00000000000000000000000000000001
const b = 2;         // 00000000000000000000000000000010

console.log(a << b); // 00000000000000000000000000000100
 
 
 
/*
run:
 
4
 
*/

 



answered Nov 15, 2020 by avibootz
0 votes
const a = 8;         // 00000000000000000000000000000101
const b = 3;         // 00000000000000000000000000000011

console.log(a << b); // 00000000000000000000000001000000
 
 // 8 << 3 = 8 * (2 ** 3) = 8 * (8) = 64
 
/*
run:
 
64
 
*/

 



answered Nov 15, 2020 by avibootz

Related questions

1 answer 262 views
1 answer 172 views
1 answer 116 views
1 answer 180 views
3 answers 210 views
...