Some Operators in JavaScript | Day 31 | Web development Course

10 months ago
7

JavaScript Operators
Operators are symbols or keywords used to perform operations on data in JavaScript. They allow you to manipulate data, compare values, and control the flow of your program.

Here are the different types of operators in JavaScript:

1. Arithmetic Operators:

+: Addition
-: Subtraction
*: Multiplication
/: Division
%: Modulo (remainder after division)
++: Increment (add 1)
--: Decrement (subtract 1)
2. Assignment Operators:

=: Assign value
+=: Add and assign
-=: Subtract and assign
*=: Multiply and assign
/=:** Divide and assign
%=: Modulo and assign
3. Comparison Operators:

==: Equal to
!=: Not equal to
===:** Strictly equal to (type and value)
!==:** Not strictly equal to
>: Greater than
<: Less than
=:** Greater than or equal to

<=:** Less than or equal to
4. Logical Operators:

&&:** And
||:** Or
!:** Not
5. Conditional (Ternary) Operator:

condition ? value1 : value2
Evaluates condition and returns value1 if true, otherwise returns value2
6. String Operators:

+: Concatenation (joins strings)
7. Bitwise Operators:

~:** Unary negation
&:** Bitwise AND
|:** Bitwise OR
^:** Bitwise XOR
<<:** Left shift
:** Right shift

8. Comma Operator:

Separates expressions and evaluates them from left to right
9. Unary Operators:

-:** Negation
!:** Logical NOT
typeof:** Returns the data type of an operand
++ and -- (prefix and postfix): Increment and decrement

Loading comments...