Nearby lessons

7 of 40

๐Ÿงฎ JavaScript Operators

๐Ÿ“Œ What are JavaScript Operators?

Operators in JavaScript are used to perform operations on values and variables. ๐Ÿ’ก

They are essential building blocks for expressions, conditions, and logic in your code.

๐Ÿ“‹ Types of Operators

  • ๐Ÿ”น Arithmetic Operators
  • ๐Ÿ”ธ Assignment Operators
  • ๐Ÿ”น Comparison Operators
  • ๐Ÿ”ธ Logical Operators
  • ๐Ÿ”น Unary Operators
  • ๐Ÿ”ธ Ternary Operator
  • ๐Ÿ”น Bitwise Operators

๐Ÿ”น Arithmetic Operators

AttributeDescription
+Addition (e.g., a + b)
-Subtraction (e.g., a - b)
*Multiplication (e.g., a * b)
/Division (e.g., a / b)
%Modulus (remainder) (e.g., a % b)
++Increment (e.g., a++)
--Decrement (e.g., a--)

๐Ÿ”ธ Assignment Operators

AttributeDescription
=Assigns value (e.g., x = 10)
+=Adds and assigns (e.g., x += 5)
-=Subtracts and assigns (e.g., x -= 5)
*=Multiplies and assigns (e.g., x *= 5)
/=Divides and assigns (e.g., x /= 5)
%=Modulus and assigns (e.g., x %= 5)

๐Ÿ”น Comparison Operators

AttributeDescription
==Equal to (abstract equality)
===Strict equal to (value and type)
!=Not equal to
!==Strict not equal to
>Greater than
<Less than
>=Greater than or equal to
<=Less than or equal to

๐Ÿ”ธ Logical Operators

AttributeDescription
&&Logical AND (true if both are true)
||Logical OR (true if at least one is true)
!Logical NOT (inverts the result)

๐Ÿ”น Unary Operator

AttributeDescription
typeofReturns the data type of a variable
deleteDeletes a property from an object

๐Ÿ”ธ Ternary Operator

AttributeDescription
condition ? trueExpr : falseExprShorthand for if-else statement

๐Ÿ”น Bitwise Operators

AttributeDescription
&AND
|OR
^XOR
~NOT
<<Left shift
>>Right shift

๐Ÿง  Test Your Knowledge

5 Questions

Progress: 0 / 5
Keep Going!JS - Arithmetic Operators