 ## JavaScript Operators

JavaScript Operators are the symbol which is used to perform operations on operands.

Operands can be values and variable.

``````10 + 20 = 30 // 10 and 20 are operands and + is operator

10 * 20 = 200 // 10 and 20 are operands and * is operator

20 - 10 = 10 // 10 and 20 are operands and - is operator

20 / 10 = 2 // 10 and 20 are operands and / is operator
``````

## Types of JavaScript Operators

• Arithmetic Operators
• Comparison Operators
• Logical Operators
• String Operators
• Assignment Operators
• Bitwise Operators
• Conditional (or ternary) Operators

## Arithmetic Operators

Arithmetic Operators are used to perform arithmetic operations between operands.

``````let a = 20;
let b = 10;

console.log('a + b = ', a + b);
// 30

// Subtraction
console.log('a - b = ', a - b);
// 10

// Multiplication
console.log('a * b = ', a * b);
// 200

// Division
console.log('a / b = ', a / b);
// 2

// Remainder
console.log('a % b = ', a % b);
// 0
``````

## Comparison Operators

Comparison Operator are used for comparison between two operands.

``````// Equal operator
console.log(0 == 0); // true
console.log(12 == '2'); // false

// not equal operator
console.log(3 != 3); // false
console.log('hello' != 'Hello'); // true

// strict equal operator
console.log(0 === 0); // true
console.log(22 === '22'); // false

``````

## Logical Operators

Logical Operator are used to perform logical operation and it return a Boolean value (true , false).

``````let a = 1, b = 2;
(a < 2) && (b > 1); // true``````

## String Operators

The + operator, and the += operator is used to concatenate strings.

``````// concatenation operator
console.log('Code' + 'Shruta');let a =0
let b=1
console.log(a & b);//0
console.log(a | b);//1
console.log(a ^ b);//1
console.log(~a);//-1
console.log(b >> 1);//0
console.log(b << 1)//2
let a = 'Hello ';
a += ' World';
console.log(a);``````

## Assignment Operators

Assignment Operators are used to assign values to variables.

``````//Addition Assignment
let x = 100;
x += 15;
console.log(x);//115

//Subtraction Assignment
let y = 100;
y -= 15;
console.log(y);//85

//Multiplication Assignment
let z = 100;
z *= 15;
console.log(z);//1500``````

## Bitwise Operators

Bitwise Operators perform operations on binary values.

``````let a =0
let b=1

//Bitwise AND
console.log(a & b);//0

//Bitwise OR
console.log(a | b);//1

//Bitwise XOR
console.log(a ^ b);//1

//Bitwise NOT
console.log(~a);//-1

//Right Shift
console.log(b >> 1);//0

//Left Shift
console.log(b << 1)//2``````

## Conditional Operators

It assign a value to a variable based on some condition.

!!JavaScript Operators !!.

Check All JavaScript Tutorial here JAVASCRIPT TUTORIAL.

Written By : Ankita Kataria.