Anthony Maximus

The Javascript Cheat Sheet

Operators

For quik maths



Operator Name Description / What It Does
+ Addition Adds two numbers or concatenates strings.
- Subtraction Subtracts the right operand from the left.
* Multiplication Multiplies two numbers.
/ Division Divides the left operand by the right.
% Modulus (Remainder) Returns the remainder of a division.
** Exponentiation Raises the left operand to the power of the right operand.
++ Increment Increases a variable by 1.
-- Decrement Decreases a variable by 1.
= Assignment Assigns a value to a variable.
+= Addition Assignment Adds and assigns a value (x += 5 is x = x + 5).
-= Subtraction Assignment Subtracts and assigns (x -= 5 is x = x - 5).
*= Multiplication Assignment Multiplies and assigns (x *= 5 is x = x * 5).
/= Division Assignment Divides and assigns (x /= 5 is x = x / 5).
%= Modulus Assignment Finds remainder and assigns (x %= 5 is x = x % 5).
**= Exponentiation Assignment Raises power and assigns (x **= 2 is x = x ** 2).
== Loose Equality Checks if values are equal (converts types if needed).
=== Strict Equality Checks if values and types are equal.
!= Loose Inequality Checks if values are not equal (converts types if needed).
!== Strict Inequality Checks if values or types are different.
> Greater Than Checks if left is greater than right.
< Less Than Checks if left is less than right.
>= Greater Than or Equal To Checks if left is greater than or equal to right.
<= Less Than or Equal To Checks if left is less than or equal to right.
&& Logical AND Returns true if both sides are true.
` `
! Logical NOT Reverses true to false and vice versa.
?? Nullish Coalescing Returns right operand if left is null or undefined.
? : Ternary Operator Shortens if-else: condition ? value_if_true : value_if_false.
& Bitwise AND Performs AND on binary values.
` ` Bitwise OR
^ Bitwise XOR Performs XOR on binary values.
~ Bitwise NOT Inverts all bits of a number.
<< Bitwise Left Shift Shifts bits left, multiplying the number.
>> Bitwise Right Shift Shifts bits right, dividing the number.
>>> Zero-Fill Right Shift Shifts bits right, filling with zeros.