Alex Rivera | Logout

JavaScript performance difference between double equals (==) and triple equals (===)

Asked 2011-11-08T00:57:55.727
50

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)

Edit
Report

1 Answer

39

Strict comparison (===) will always be slightly faster, but the difference is usually negligible.

It definitely makes sense to prefer === if you know for certain that you don't need type coercion in the comparison. It will always be at least as fast as ==.

answered 2011-11-08T01:06:05.390

Your Answer