4 ms·
Lazy response, excerpted from a blog post[1]: One particular weirdness and unpleasantry in JavaScript is the set of equality operators. Like virtually every la
by bcherry 14y ago
Lazy response, excerpted from a blog post[1]:
One particular weirdness and unpleasantry in JavaScript is the set of equality operators. Like virtually every language, JavaScript has the standard ==, !=, <, >, <=, and >= operators. However, == and != are NOT the operators most would think they are. These operators do type coercion, which is why [0] == 0 and "\n0\t " == 0 both evaluate to true. This is considered, by sane people, to be a bad thing. Luckily, JavaScript does provide a normal set of equality operators, which do what you expect: === and !==. It sucks that we need these at all, and === is a pain to type, but at least [0] !== 0.
[1]: Post from my blog, but I'm not linking to it because the rest is not useful to answer this question and I don't want to come across as a self-promoting-link-whore :)
- wingerlang 14y agoIt is not self promotion if someone asks for it. So how about a link.
- logn 14y agohttp://www.adequatelygood.com/2010/3/Performance-of-vs- http://www.adequatelygood.com/2010/3/Performance-of-vs-