JS Tutorial



JS OPERATORS


JavaScript Operators

JavaScript operators are special symbols used to perform operations on values and variables. These operations can include arithmetic, comparison, assignment, logic, and more.

🧠 Why Learn This?
Operators are the building blocks of logic in programming. You’ll use them everywhere — from calculations to decision-making!

🔢 1. Arithmetic Operators

  • + Addition
  • - Subtraction
  • * Multiplication
  • / Division
  • % Modulus (remainder)
  • ** Exponentiation
let a = 5;
let b = 2;

console.log(a + b);  // 7
console.log(a % b);  // 1
console.log(a ** b); // 25
  

🎯 2. Assignment Operators

Used to assign values to variables.

  • = Simple assignment
  • +=, -=, *=, etc.
let x = 10;
x += 5; // x becomes 15
  

⚖️ 3. Comparison Operators

Used to compare two values:

  • == Equal to (loose)
  • === Equal to (strict)
  • != Not equal
  • !== Strict not equal
  • >, <, >=, <=
let a = 5;
console.log(a == "5");   // true (type ignored)
console.log(a === "5");  // false (type compared)
  

🔀 4. Logical Operators

Used to combine multiple conditions:

  • && AND
  • || OR
  • ! NOT
let isLoggedIn = true;
let isAdmin = false;

console.log(isLoggedIn && isAdmin); // false
console.log(!isAdmin);              // true
  

🚀 Try it Yourself!

Click the button below to see different operators in action:

Output will appear here

💡 Other Important Operators

  • typeof → Tells the data type
  • instanceof → Checks object type
  • ?? → Nullish coalescing (returns right-hand value if left is null/undefined)
  • ?: → Ternary operator for quick conditionals
let name;
let display = name ?? "Guest";
console.log(display); // Guest
  
📌 Summary:
Operators are essential tools in JavaScript. From basic math to logic and control, they make coding powerful and expressive.

🌟 Enjoyed Learning with Us?

Help others discover Technorank Learning by sharing your honest experience.
Your support inspires us to keep building!

Leave a Google Review