Operators in JavaScript (OCR A-Level Computer Science): Revision Notes
📚 Revision Notes
Operators in JavaScript
Overview
JavaScript supports various operators for arithmetic, assignment, comparison, and logical operations, enabling data manipulation and decision-making.
Key Concepts
- Arithmetic Operators:
+,-,*,/,%. - Comparison Operators:
==,===,!=,<,>. - Logical Operators:
&&,||,!.
lightbulbExample
Example:
let result = 10 + 5; // Arithmetic
let isEqual = (result === 15); // Comparison
let isValid = isEqual && true; // Logical
Common Mistakes
- Misusing
==and===:===checks both value and type.
infoNote
Key Takeaways
- Use the appropriate operator for each task.
- Practice with logical and comparison operators to avoid common errors.