3775 56 528360
Google Tech Talks
presented by Doug Crockford
February 27, 2009
Speaker: Douglas Crockford
By 19eightyfour 2017-09-20
By anonymous 2017-09-20
always Until you fully understand the differences and implications of using the
=== operators, use the
=== operator since it will save you from obscure (non-obvious) bugs and WTFs. The "regular"
== operator can have very unexpected results due to the type-coercion internally, so using
=== is always the recommended approach.
The You Don't Know JS series by Kyle Simpson is excellent (and free to read online). The series goes into the commonly misunderstood areas of the language and explains the "bad parts" that Crockford suggests you avoid. By understanding them you can make proper use of them and avoid the pitfalls.
To boil down a whole lot of details to a few simple takeaways, and help you know whether to use
===in various situations, here are my simple rules:
- If either value (aka side) in a comparison could be the
- If either value in a comparison could be of these specific values (
-- empty array), avoid
- In all other cases, you're safe to use
==. Not only is it safe, but in many cases it simplifies your code in a way that improves readability.
Popular Videos 25
Submit Your Video