Main Menu

Pages

JavaScript Tutorial #3: Operators and Expressions - Spider Cyber Team


JavaScript Tutorial #3: Operators and Expressions

Welcome back to the Spider Cyber Team JavaScript series. Now that you know how to store data in variables, it's time to learn how to manipulate that data using Operators.


1. Arithmetic Operators

These are used to perform standard mathematical calculations:

  • + (Addition): Adds numbers or joins strings.
  • - (Subtraction): Subtracts numbers.
  • * (Multiplication): Multiplies numbers.
  • / (Division): Divides numbers.
  • % (Modulus): Returns the division remainder.
  • ** (Exponentiation): Raises to a power (ES6).

let x = 10;
let y = 3;

console.log(x + y); // 13
console.log(x % y); // 1 (Remainder of 10/3)
console.log(x ** 2); // 100 (10 squared)

2. Assignment Operators

Used to assign values to variables. The most common is =, but there are shortcuts:

  • x += 5 (Same as x = x + 5)
  • x -= 2 (Same as x = x - 2)

3. Comparison Operators

Essential for logic, these return a Boolean (true or false):

  • == : Equal to (checks value).
  • === : Strict equal (checks value AND type).
  • != : Not equal.
  • > / < : Greater than / Less than.

let a = 5;
let b = "5";

console.log(a == b);  // true (values are same)
console.log(a === b); // false (different types: number vs string)

4. Logical Operators

Used to combine multiple conditions:

  • && (AND): True if both are true.
  • || (OR): True if at least one is true.
  • ! (NOT): Reverses the result.

Conclusion

Operators allow your code to "think" and calculate. In the next lesson, we will use these operators with If-Else Statements to control the flow of our programs!

Master JavaScript Today!

Get the latest JS tips and cyber security scripts on our Telegram:

Join Spider Cyber Team
Keywords: JavaScript Operators, Arithmetic vs Logical operators, JS assignment operators, JavaScript Tutorial for beginners, Spider Cyber Team coding, learn JavaScript 2026, JS comparison operators.

Comments