0d: 00h: 00m: 00s

🎁 Get 3 extra months of learning β€” completely FREE

That's 90 extra days to master new skills, build more projects, and land your dream job.

Become a PRO
Background Image

🎁 Get 3 extra months of learning completely FREE

Become a PRO
Jacob Harvey
PRO
2 months ago
Jacobcountry asked

In JavaScript, what is the difference between equal to (==) and strictly equal to (===)?

Abhay Jajodia
Expert
yesterday
Abhay Jajodia answered

Hi Jacob,

== compares values after JavaScript may convert one type to another (type coercion).
=== compares both the value and the type, with no conversion.

Example:

5 == "5"    // true (string "5" is converted to number)
5 === "5"   // false (number vs string)

Most of the time, === is safer because it avoids surprising conversions.

If you have more questions, I am here to help 😊

JS
This question was asked as part of the Learn JavaScript Basics course.