Search This Blog

Monday, July 15, 2019

Difference between == and === in JavaScript

The ‘==’ operator tests for abstract equality i.e. it does the necessary type conversions before doing the equality comparison.

But the ‘===’ operator tests for strict equality i.e it will not do the type conversion hence if the two values are not of the same type, when compared, it will return false.


x = 5  
x == 8 return false
x == "5" return true
x == 5  return true

x === 5   return true
x === "5"  return false

No comments :