Knowing the difference between a loose and strict comparison is important, and handy as hell when it comes to things like returning a valid string value or boolean false so you can gracefully error handle.
false == (0 || null || "" || void)
false !== (0 || null || "" || void)
If you can't keep that difference straight, and understand why there's a difference and why it's important, you probably shouldn't be writing JavaScript (or any other loosely typed language) in the first place!!!
It's like the halfwits who pretend they know C but rail against the difference between ++a and a++... if you can't understand it or realize why it's important, do the world a favor, back the $%^& away from the keyboard, and go take up something a bit less detail oriented like macramé.
They don't mean the same, or should not mean the same. === is a Boolean comparison or what ever the real term is
Why is a mix bad?
According to this there really is no difference unless your comparing types and for most if statements, == is perfectly fine.
Peter Scheler
JS enthusiast
To clear this out:
Loose equals (
==) uses coercion, strict equals (===) does not.It's not a question of what is faster/recommended/preferred. It's only a question of what you want to do. (Most times strict equals are the right choice, but not in every case)
Read this!