w1coding.comAll tutorials

JavaScript Operators

JavaScript lessons
  1. Environment Setup
  2. Introduction
  3. Enviroment
  4. Basics
  5. Variables
  6. Operators
  7. Condition
  8. Functions
  9. Arrays
  10. Bjects
  11. DOM
  12. Objects
  13. Colors
  14. DOM
  15. Events
  16. Validation
  17. JSON
  18. Error
  19. Callbacks
  20. Promises
  21. Fetch
  22. Local
  23. Modules
  24. Animation
  25. Classes
  26. Iframes
  27. Responsive

Operators in JavaScript

Operators are symbols that allow us to perform operations on variables and values.

Types of Operators

  • Arithmetic Operators: Used for mathematical calculations (+, -, *, /).
  • Assignment Operators: Assign values to variables (=, +=, -=).
  • Comparison Operators: Compare values (==, ===, !=, >, <).
  • Logical Operators: Used for logical operations (&&, ||, !).

Example: Arithmetic Operators

      
        let x = 5;
        let y = 3;
        console.log(x + y); // 8
        console.log(x * y); // 15
      
    

Activity

Try It Yourself!

Use different operators with x = 10 and y = 2 to see the results.

Quiz

Quick Quiz

  1. What operator would you use to add two numbers?
  2. Which operator is used for strict equality?
  3. What does the && operator represent?

Answers: +; ===; logical AND.