JS-031

Beginner3 min~3 min read#comparison#operators#boolean
Comparison
Comparing values
Goal
Understand that a comparison always returns true or false.
Explanation
- Comparison means checking two values against each other.
- JavaScript can test whether values are equal, different, greater, or less.
- The result of a comparison is always a boolean: true or false.
- If the condition is correct, the result is true.
- If the condition is wrong, the result is false.
Analogy
A comparison is like a yes-or-no question. JavaScript looks at two values and answers true or false.
Code
console.log(5 === 5);
console.log(5 === 10);Result: true false
Common mistake
Beginners sometimes expect a comparison to return the value itself. In reality, it returns only true or false.
Remember
- ✦ A comparison returns a boolean.
- ✦ true means the check passed.
- ✦ false means the check failed.
Quick Quiz
What does a comparison return?