## JavaScript Operators

### List of JavaScript Operator

- Arithmetic Operators
- Comparision Operators
- Logical (or Relational) Operators
- Assignment Operators
- Conditional (or ternary) Operators

### Arithmetic Operators

1. + (Addition)

10 + 5 will give 15 is output.

2. - (Subtraction)

10 - 5 will give 5 is output.

3. * (Multiplication)

10 * 5 will give 50 is output.

4. / (Division)

10 / 5 will give 2 is output.

5. % (Modulus)

5 % 2 will give 1 is output.

6. ++ (Increment)

var data = 5;

data++;

will give 6 is output.

7. -- (Decrement)

var data = 5;

data--

will give 4 is output.

Note. + (Addition)

work with both number and string.

var data1 = "W3";

var data2 = "Tricks";

data1 + data2 will give "W3Tricks" is output.

10 + 5 will give 15 is output.

2. - (Subtraction)

10 - 5 will give 5 is output.

3. * (Multiplication)

10 * 5 will give 50 is output.

4. / (Division)

10 / 5 will give 2 is output.

5. % (Modulus)

5 % 2 will give 1 is output.

6. ++ (Increment)

var data = 5;

data++;

will give 6 is output.

7. -- (Decrement)

var data = 5;

data--

will give 4 is output.

Note. + (Addition)

work with both number and string.

var data1 = "W3";

var data2 = "Tricks";

data1 + data2 will give "W3Tricks" is output.

### Comparison Operators

1. = = (Equal)

A == B

To Check A and B operands are equal? Yes or No.

2. != (Not Equal)

A != B

To Check A and B operands are equal? Yes or No.

3. > (Greater than)

A > B

To check A is greater than to B? Yes or No.

4. < (Less than)

To check A is less than to B? Yes or No.

5. >= (Greater than or Equal to)

To Check A is greater than or equal to B.

6. <= (Less than or Equal to)

To Check A is Less than or equal to B.

A == B

To Check A and B operands are equal? Yes or No.

2. != (Not Equal)

A != B

To Check A and B operands are equal? Yes or No.

3. > (Greater than)

A > B

To check A is greater than to B? Yes or No.

4. < (Less than)

To check A is less than to B? Yes or No.

5. >= (Greater than or Equal to)

To Check A is greater than or equal to B.

6. <= (Less than or Equal to)

To Check A is Less than or equal to B.

### Logical Operators

1. && (Logical AND)

( A==5 && B==10 )

check a A and B both value is true ?

2. || (Logical OR)

( A==5 || B==10 )

In one value is true then the condition becomes true.

operand

3. ! (Logical NOT)

!(A=5)

If a condition is true, then output is false.

( A==5 && B==10 )

check a A and B both value is true ?

2. || (Logical OR)

( A==5 || B==10 )

In one value is true then the condition becomes true.

operand

3. ! (Logical NOT)

!(A=5)

If a condition is true, then output is false.

### Bitwise Operators

1. & (Bitwise AND)

2. | (BitWise OR)

3. ^ (Bitwise XOR)

4. ~ (Bitwise Not)

5. << (Left Shift)

6. >> (Right Shift)

7. >>> (Right shift with Zero)

2. | (BitWise OR)

3. ^ (Bitwise XOR)

4. ~ (Bitwise Not)

5. << (Left Shift)

6. >> (Right Shift)

7. >>> (Right shift with Zero)

### Assignment Operators

1. = (Simple Assignment )

A = 5

Assigns values to operand.

2. += (Add and Assignment)

A += 5 both are same A = A + 5

3. −= (Subtract and Assignment)

A -= 5 both are same A = A - 5

4. *= (Multiply and Assignment)

A*=5 both are same A = A * 5

5. /= (Divide and Assignment)

A/=5 both are same A = A / 5

6. %= (Modules and Assignment)

A %= 5 toth are same A = A % 5

A = 5

Assigns values to operand.

2. += (Add and Assignment)

A += 5 both are same A = A + 5

3. −= (Subtract and Assignment)

A -= 5 both are same A = A - 5

4. *= (Multiply and Assignment)

A*=5 both are same A = A * 5

5. /= (Divide and Assignment)

A/=5 both are same A = A / 5

6. %= (Modules and Assignment)

A %= 5 toth are same A = A % 5

### Miscellaneous Operator

conditional operator (? :)

Ex:

max Number of two number

Ans = (A > B ? 5 : 10)

Ans is 10

Ex:

max Number of two number

Ans = (A > B ? 5 : 10)

Ans is 10

## 0 comments:

## Post a Comment