Junior — Middle
What is the role of the triple equals operator in comparing values in a programming language?
sobes.tech AI
Answer from AI
In JavaScript (and Node.js), the triple equals operator === is used for strict comparison of two values. Unlike the double equals ==, which performs type coercion before comparison, === compares both value and type without coercion.
For example:
1 == '1' // true, because '1' is coerced to number 1
1 === '1' // false, different types (number and string)
true == 1 // true
true === 1 // false
Using === is recommended to prevent unexpected results due to implicit type conversion.