What Does "Right Shift" Do in JavaScript? 😳 #coding #shorts #programming #javascript #frontend
Signed Right Shift in JavaScript
❓ Question:
What’s the output of this signed right shift operation?
JavaScript’s bitwise operators are sneakier than you think!
Can you figure it out without running the code?
💬 Drop your guess below & tag a dev friend to try too!
🔔 Subscribe for daily JS logic tests: https://www.youtube.com/@UCRSKgFBDAELKW2S7ySZDm4A
✅ Explanation:
In JavaScript, Right Shift is the signed right shift operator. It shifts the bits to the right while preserving the sign bit (which indicates positive or negative).
🔍 Step-by-Step Breakdown:
The binary of -8 in 32-bit two's complement is:
11111111 11111111 11111111 11111000
Now we shift the bits to the right by 2 using Right Shift.
Because this is a signed shift, the sign bit (1 for negative) is preserved.
Resulting binary:
11111111 11111111 11111111 11111110
This binary equals -2 in decimal.
🧠 Key Takeaway:
Right Shift keeps the sign (negative stays negative).
This is different from unsigned right shift, which fills with 0s and always gives a positive result.
#shortsfeed #javascript #BitwiseOperators #rightshift #CodingQuiz #javascripttips #LearnJavaScript #frontenddevelopment #shortsvideo #video #codechallenge #coding #js #popular #coder #javascriptinterview
#interview
Видео What Does "Right Shift" Do in JavaScript? 😳 #coding #shorts #programming #javascript #frontend канала FrontEndGuru
❓ Question:
What’s the output of this signed right shift operation?
JavaScript’s bitwise operators are sneakier than you think!
Can you figure it out without running the code?
💬 Drop your guess below & tag a dev friend to try too!
🔔 Subscribe for daily JS logic tests: https://www.youtube.com/@UCRSKgFBDAELKW2S7ySZDm4A
✅ Explanation:
In JavaScript, Right Shift is the signed right shift operator. It shifts the bits to the right while preserving the sign bit (which indicates positive or negative).
🔍 Step-by-Step Breakdown:
The binary of -8 in 32-bit two's complement is:
11111111 11111111 11111111 11111000
Now we shift the bits to the right by 2 using Right Shift.
Because this is a signed shift, the sign bit (1 for negative) is preserved.
Resulting binary:
11111111 11111111 11111111 11111110
This binary equals -2 in decimal.
🧠 Key Takeaway:
Right Shift keeps the sign (negative stays negative).
This is different from unsigned right shift, which fills with 0s and always gives a positive result.
#shortsfeed #javascript #BitwiseOperators #rightshift #CodingQuiz #javascripttips #LearnJavaScript #frontenddevelopment #shortsvideo #video #codechallenge #coding #js #popular #coder #javascriptinterview
#interview
Видео What Does "Right Shift" Do in JavaScript? 😳 #coding #shorts #programming #javascript #frontend канала FrontEndGuru
Комментарии отсутствуют
Информация о видео
4 июня 2025 г. 12:37:26
00:00:18
Другие видео канала