Let's see the operators in Javascript.

```
var a = 10
var b = 5
```

Here if we can use the Arithmetic Operators. What does Arithmetic Operator do? Arithmetic operators combine with numbers to form an expression that returns a single number.

```
console.log(a + b);
console.log(a - b);
console.log(a / b);
console.log(a * b);
```

Here each of the `console.log`

will give the respective answers - 15, 5, 2, 50.

Similar to the Arithmetic operators we have the modulus. Modulus returns the remainder between two numbers.

```
console.log (a%b)
```

There are also comparison operators. There are problems in which we need to make decisions in coding. All decisions really comes down to making a comparison. Two values comparing to each other to ultimately determine a true or false result. Comparison operators combine with strings, booleans and numbers to form an expression that evaluates to true or false.

Beginners often gets confused when asked the difference between

`==`

and`===`

Here`==`

compares equality.

For example`console.log(b == c);`

where`b ="50"`

and`c =50`

. Here both the values are 50 while one is a string data type and other is a number. Here in this example`b==c`

is true while`b===c`

is false. That is because`===`

Compares equality and type (strict equality).

Other comparison operators are -

- Greater than or less than
- Greater than or equal to and less than or equal to

```
var a = 100;
var b = 10;
var c = "10";
var expression1 = (b == c);
var expression2 = (a > b);
```

- && - When we do
`console.log(expression1 && expression2);`

, evaluates to true if expression1 AND expression2 are both true, otherwise false - || - Similarly if we use || operator, evaluates to true if expression1 OR expression2 is true, otherwise false

## Top comments (0)