In JavaScript, is there a performance difference between using a double equals (==) vs using a triple equals (===)?
==
===
Example: if (foo == bar) vs if (foo === bar)
if (foo == bar)
if (foo === bar)
If the types compared are the same, they are identical. That is to say they use the exact same algorithm.
If the types are different, then performance is irrelevant. Either you need type coercion, or you don't. If you don't need it, don't use == because the result you get may be unexpected.
2.1m questions
2.1m answers
60 comments
57.0k users