They basically do the same thing, but there is a big difference between the two.
In particular we have value types (Boolean, null, undefined, String and Number) and reference types (Array, Object, Function).
If two values are not of the same type,
=== will return false.
With reference types, this means the values need to reference the same object / array / function. Not one with the same values: the same one.
== is different because it will attempt to convert types to match.
This is why you get results like
false == '0' //true false === '0' //false null == undefined //true null === undefined //false
In my experience, in 97% of the cases you’ll want to use
== provides exactly what you want. It has less drawbacks and edge cases.
The same goes for
!==, which perform the same thing, but negated.
Always default to
Here's my latest YouTube video. I talk about work/life balance as a developer: