Arithmetic Operators
Arithmetic operators are used for performing mathematical operations.
+
: Addition-
: Subtraction*
: Multiplication/
: Division%
: Modulus (remainder)**
: Exponentiation
Comparison Operators
Comparison operators are used to compare values.
==
: Equal to (equality, without type checking)===
: Strict equal to (equality with type checking)!=
: Not equal to (inequality, without type checking)!==
: Strict not equal to (inequality with type checking)>
: Greater than<
: Less than>=
: Greater than or equal to<=
: Less than or equal to
Logical Operators
Logical operators are used to combine or modify Boolean values.
&&
: Logical AND (true if both operands are true)||
: Logical OR (true if at least one operand is true)!
: Logical NOT (inverts the Boolean value)
Assignment Operators
Assignment operators are used to assign values to variables.
=
: Assigns the value on the right to the variable on the left+=
: Adds the right operand to the left operand and assigns the result to the left operand-=
: Subtracts the right operand from the left operand and assigns the result to the left operand*=
: Multiplies the left operand by the right operand and assigns the result to the left operand/=
: Divides the left operand by the right operand and assigns the result to the left operand%=
: Computes the modulus of the left operand and the right operand and assigns the result to the left operand
Bitwise Operators
Bitwise operators perform operations on binary representations of numbers.
&
: Bitwise AND|
: Bitwise OR^
: Bitwise XOR (exclusive OR)~
: Bitwise NOT (complement)<<
: Left Shift>>
: Right Shift>>>
: Unsigned Right Shift
Conditional (Ternary) Operator
The conditional operator is used to assign a value to a variable based on a condition.
condition ? value1 : value2
: If the condition is true,value1
is assigned; otherwise,value2
is assigned.
Typeof Operator
The typeof
operator is used to determine the type of a value or variable.
typeof x
: Returns a string indicating the data type ofx
.
Instanceof Operator
The instanceof
operator is used to check if an object is an instance of a particular class or constructor.
object instanceof constructor
: Returnstrue
ifobject
is an instance ofconstructor
.
In Operator
The in
operator is used to check if a property exists in an object.
property in object
: Returnstrue
ifproperty
is found inobject
.
Reference: