What is the difference between `==` and `===` when comparing `1` and `’1’`?

JavaScript Associate Medium

JavaScript Associate — Medium

What is the difference between `==` and `===` when comparing `1` and `’1’`?

Key points

  • `==` coerces values before comparison
  • `===` checks both value and type
  • `1` and `'1'` have different types
  • Type coercion can lead to unexpected results

Ready to go further?

Related questions