operations:
An operator is a symbol or keyword in programming that performs a specific mathematical or logical operation on one or more values called operands.
types of operators:
Arithmetic Operators:
Perform mathematical calculations.
+ (Addition)
- (Subtraction)
* (Multiplication)
/ (Division)
% (Modulus - returns the remainder of a division)
** (Exponentiation)
++ (Increment - increases value by 1)
-- (Decrement - decreases value by 1)
Assignment Operators:
Assign values to variables.
= (Simple assignment)
+= (Add and assign)
-= (Subtract and assign)
*= (Multiply and assign)
/= (Divide and assign)
%= (Modulus and assign)
**= (Exponentiation and assign)
Comparison Operators:
Compare two values and return a boolean (true or false) result.
== (Loose equality - compares values after type coercion)
=== (Strict equality - compares values and types)
!= (Loose inequality)
!== (Strict inequality)
> (Greater than)
< (Less than)
>= (Greater than or equal to)
<= (Less than or equal to)
Logical Operators:
Combine or manipulate boolean values.
&& (Logical AND)
|| (Logical OR)
! (Logical NOT)
Bitwise Operators:
Perform operations on the binary representation of numbers.
& (Bitwise AND)
| (Bitwise OR)
^ (Bitwise XOR)
~ (Bitwise NOT)
<< (Left shift)
>> (Sign-propagating right shift)
>>> (Zero-fill right shift)
Ternary (Conditional) Operator:
A shorthand for an if-else statement.
condition ? expressionIfTrue : expressionIfFalse
Unary Operators:
Operate on a single operand. Examples include typeof, delete, void, + (unary plus), - (unary negation).
String Operators:
Primarily the + operator for string concatenation.
Type Operators:
typeof: Returns the data type of an operand as a string.
instanceof: Checks if an object is an instance of a particular class or constructor function.
Top comments (0)