In JavaScript, operators are symbols that are used to perform operations on operands. Operands can be variables, values, or expressions. JavaScript supports various types of operators, including arithmetic, assignment, comparison, logical, bitwise, and more. Here’s a brief overview of some common types of operators in JavaScript:
Arithmetic Operators: Used to perform mathematical operations.
+
(Addition)-
(Subtraction)*
(Multiplication)/
(Division)%
(Modulus – returns the remainder of a division)++
(Increment)--
(Decrement)
Assignment Operators: Used to assign values to variables.
=
(Assignment)+=
,-=
,*=
,/=
,%=
(Compound assignment)
Comparison Operators: Used to compare values.
==
(Equal to)===
(Strict equal to)!=
(Not equal to)!==
(Strict not equal to)>
(Greater than)<
(Less than)>=
(Greater than or equal to)<=
(Less than or equal to)
Logical Operators: Used to combine or manipulate boolean values.
&&
(Logical AND)||
(Logical OR)!
(Logical NOT)
Bitwise Operators: Used to manipulate the binary representation of numbers.
&
(Bitwise AND)|
(Bitwise OR)^
(Bitwise XOR)<<
(Left shift)>>
(Right shift)>>>
(Unsigned right shift)~
(Bitwise NOT)
Conditional (Ternary) Operator: A shorthand for the if…else statement.
condition ? expr1 : expr2
Typeof Operator: Used to determine the type of a variable or expression.
typeof
Instanceof Operator: Used to check whether an object is an instance of a specific class or constructor.
instanceof