ā¤ Like
šŸ”– Save
šŸ”— Share
@thedevspaceio
@thedevspaceio

JavaScript Operators Cheatsheet

@thedevspaceio

🧮 JavaScript Operators Cheatsheet

Operators perform actions on values and variables. This cheatsheet covers arithmetic, comparison, logical, assignment, and modern operators you use every day.

āœ… Arithmetic operators āœ… Comparison operators āœ… Logical operators āœ… Assignment operators āœ… Unary operators āœ… Ternary operator āœ… Optional chaining āœ… Nullish coalescing

#javascript #operators #arithmetic #comparison #logical #syntax #webdev #frontend #coding #tips


Arithmetic operators

OperatorNameExampleResult
+Addition5 + 38
-Subtraction5 - 32
*Multiplication5 * 315
/Division6 / 32
%Remainder7 % 31
**Exponentiation2 ** 38

Comparison operators

OperatorNameExampleResult
==Loose equality5 == "5"true
===Strict equality5 === "5"false
!=Loose inequality5 != "5"false
!==Strict inequality5 !== "5"true
>Greater than5 > 3true
<Less than5 < 3false
>=Greater or equal5 >= 5true
<=Less or equal5 <= 4false

Logical operators

OperatorNameDescription
||ORReturns first truthy value or last value
&&ANDReturns first falsy value or last value
!NOTConverts to boolean and inverts
??Nullish coalescingReturns right side only if left is null or undefined

Assignment operators

OperatorExampleEquivalent
=x = 5x = 5
+=x += 5x = x + 5
-=x -= 5x = x - 5
*=x *= 5x = x * 5
/=x /= 5x = x / 5
%=x %= 5x = x % 5
**=x **= 2x = x ** 2

Unary operators

OperatorNameExampleResult
++Incrementlet x = 5; x++6
--Decrementlet x = 5; x--4
+Unary plus+"42"42
-Unary negation-(5)-5
typeofType checktypeof 5"number"
deleteDelete propertydelete obj.xremoves x

Ternary operator

A compact alternative for if...else expression.

js
const age = 20;
const status = age >= 18 ? "adult" : "minor";
 
console.log(status); // "adult"

Optional chaining (?.)

Safely access nested properties without throwing if a reference is null or undefined.

js
const user = { profile: { name: "Ada" } };
console.log(user.profile?.name); // "Ada"
console.log(user.settings?.theme); // undefined

Nullish coalescing (??)

Returns the right-hand value, only when the left-hand side is null or undefined.

js
const value = 0;
console.log(value ?? 10); // 0
 
const missing = null;
console.log(missing ?? "fallback"); // "fallback"

Full-Stack AI Developer Roadmap

From HTML & CSS to working with AI models, all in one structured roadmap.

@thedevspaceio
www.thedevspace.io