Bitwise Operators

Short & Sweet series — part 1

Michal Porag
3 min readMar 25, 2020

Following the COVID-19 crisis that requires me to stay at home these days, I use the free time to promote myself to the goal of expert Front End developer.
As part of my learning process, I decided that over the coming period and as long as I will stay at home, I will try to share every day one interesting thing that I learn on this day. I will do it in the form of a short summary with relevant links.

I hope this experience will help, me and you, to keep learning new exciting things even during these difficult days.❤️

What operators are?

A sign or word which set in the language and behaves, generally, like functions on given operands.

Of course, I didn’t know either what is “operands”.

In mathematics, an operand is the object of a mathematical operation, i.e., it is the object or quantity that is operated on.

JavaScript has 51 operators that are divided into 10 categories:

For a long time I thought that I knew all JavaScript operators, but last week, when I’ve started to read “The C Programming Language” (by K&R), I have reached the part on the book that explains the Bitwise operators, and curiously, I decided to check if there is any equivalent in JavaScript.

I was surprised to find there is. :)

What Bitwise Operators are?

Bitwise operators let us do bit manipulations. In C, we can use Bitwise operators only on char, short, int, and long operands. But in JS, they are limited to operands of number type only.

So why do we still need Bitwise operators in JavaScript?

The main reason to use Bitwise operators (in all languages) is for efficiency.

As you probably know, efficiency is not a very high priority on Front End development. But there is a usage of Bitwise operators on numerical conversions/computations.

The problem and the main reason that we do not use Bitewise in day to day work is that the use of the Bitwise operator creates an uncomfortable code that is not self-explaining.

The Bitwise operators:

* An interesting fact is that the last operator in the list, “Zero-fill right shift”, does not exist in the C language.

Linke to other articles from this series:

Final Words

I hope you’ve enjoyed this article and learned new things.
If you like this post, I would appreciate applause and sharing :-)
If you have something to add or change I would love to hear ❤️

Who Am I?
My name is Michal Porag. I am a Full-Stack Developer working at Skillset and a Computer Science student at The Open University.

You can contact or follow me:
Twitter

My Youtube Chanel
Facebook
LinkedIn

Resources

--

--

Michal Porag

Front-End Developer at Gong & Pull Request community leader