operators in javaScript

operators in javaScript

In JavaScript, operators are symbols or keywords used to perform operations on one or more values (operands). There are several types of operators in JavaScript, including:

1. Arithmetic operators :

Used to perform mathematical operations on operands. Examples include + (addition), - (subtraction), * (multiplication), / (division), % (modulus), and ++ (increment) and -- (decrement).

2.Comparison operators :

Used to compare two values and return a boolean value (true or false). Examples include == (equal to), != (not equal to), === (strictly equal to), !== (strictly not equal to), < (less than), > (greater than), <= (less than or equal to), and >= (greater than or equal to).

3.Logical operators :

Used to perform logical operations on boolean values. Examples include && (logical AND), || (logical OR), and ! (logical NOT).

4.Assignment operators :

Used to assign values to variables or modify the values of variables. Examples include = (assignment), += (addition assignment), -= (subtraction assignment), *= (multiplication assignment), /= (division assignment), %= (modulus assignment), <<= (left shift assignment), >>= (right shift assignment), &= (bitwise AND assignment), ^= (bitwise XOR assignment), and |= (bitwise OR assignment).

5.Bitwise operators :

Used to perform bitwise operations on operands. Examples include & (bitwise AND), | (bitwise OR), ^ (bitwise XOR), ~ (bitwise NOT), << (left shift), and >> (right shift).

6.Conditional (ternary) operator :

Used to assign a value to a variable based on a condition. The syntax is condition ? value1 : value2. If the condition is true, value1 is assigned to the variable. Otherwise, value2 is assigned.

7.typeof operator :

Used to determine the type of a value. The typeof operator returns a string indicating the data type of the operand.