Back to Developer Roadmap

Equality Operators

src/data/question-groups/javascript/content/equality-operators.md

4.0470 B
Original Source

"==" and "===" are comparison operators, but they are different in how they treat type coercion. The "==" comparison operator checks if the values are the same, but doesn't care about the data type.

The "===" comparison operator, on the other hand, checks if both the value and the data type are the same.

console.log(50 == "50"); True: string "50" is converted to number 50

console.log(50 === "50"); False: false, no type coercion due to different data types