## Shorthand Assignment with Others Operators

In this article,  we will learn assignment operator. On many occasions, you use the assignment operator to assign value or to evaluate the values of two operands. The assignment operator is really very straightforward as the name implies assignment operator assigns a value to a variable. So we recall the previous lectures we use the assignment operator to assign the value to a variable and you also use it in many expressions.

In previous articles, we use the assignment operator to assign the value to the variable object and array. We also showed you how to use chaining system to assign the value to the variable. like this

But the assignment operator is not as limited as you are thinking of. Using the assignment operator you can do arithmetic and bitwise operation. So let’s take an example with some features of the assignment operator to minimize your code.

The following shorthand assignment operator would be the convenience when you are working with the Arithmetic and bitwise operator.

If you have to operand and you wanted to first add them and assign its value to the first operand then the code would look like this.

So if we declare two variables X and Y with some values.

Now using the assignment operator you can perform the same operation. just like this

x += y;

So this statement equivalent to the previous one.  So this statement first performs the addition and then assign the value to the first operand.

Ehen you execute this statement the value would be 15 again.  So this statement is equivalent to the previous statement. so it will first perform the addition of two operands and specify the addition new value to the first operand.

right.

#### Different type of Assignment Operator

##### Reminder

Now the assignment operator is not Limited for the Arithmetic operators but using the assignment operator you can perform bitwise operator also.

Here is the exampl of bitwise operators.

##### XOR

That’s it we know that how to use the assignment operator in the program. When you’re making a thousand line of code then shorthand assignment operator is very helpful to minimize your code.

#### Typeof Operator

Now you first take a look at the typeof operator. Typeof operator mostly used to check the type of its operand. So the typeof operator return string representing the type of its operand. Unfortunately, Typeof operator doesn’t exactly map to the 7 data type in JavaScript. So the seven data types are undefined, null, boolean, number, string, symbol, and an object.

Which has caused no end of confusion.

So let’s take an example and understand how typeof operator work. If you wanted to find out typeof the variable then this operator helps you out. So if you have  1 then using typeof operator you can find out its type.

Like this.

Type of operator return object when you check the no operator. It usually referred to as a bug. Because now it, not an object, of course, it is the primitive type. It has been suggested many time that it fixes, but the too much existing code is already built on this behaviour.

Memorize this as a exception.

##### Comma (,)Operator

comma operator simply provides a simple way to separate expression.
Just like this.

so here we use the comma operator to separate two different variables. as simple as that.

##### Grouping ()Operator

So the grouping operator is a parenthesis. Parentheses used to specify the order of the operation. We will use grouping operator to specify operator precedence. We will talk about this in the future articles so don’t worry we will cover everything step by step.

##### VoidOperator

You think this operator is useless because this operator has only one job. So this operator will evaluate its operand and return undefined.

This operator used when you wanted to return the undefined value.

So where do you use it?  there is the different situation where you can use this operator suppose if you wanted to create an anchor tag in HTML and when you click on the anchor link then the browser will take you to another page. to prevent this behavior I will just use the following code.

So that is how you can use this void operator in the javascript.

That’s it. Everything has completed. we complete the assignment operator. We will explore javascript more in the future lectures. we also take a brief look at the function and more interesting aspect of javascript. That is all for this lecture.

We will see you in the next tutorial.