The ===
operator will be faster than the ==
operator. This is because ===
doesn't need to check multiple comparisons, while ==
does (i.e., ==
performs conversions).
return "true" == true; //true
The above will first test to see if "true" === true
which is false, then check "true" === "true"
(i.e., it converts the bool to a string, then checks again).
Read the comments below. You can also look at these two benchmarks as sort of guides:
For future reference, though, they really aren't the same thing and you shouldn't use them interchangeably. In fact, there aren't many any cases you'd really want to use ==
over ===
. It'll usually lead to unexpected or seemingly random results while the main point of programming is to create an interface your user can travel on. With conditions that don't always evaluate to what you originally test for, programs can turn out to be buggy, messy, or unreliable.