Equality operators with the same types

JavaScript performance comparison

Revision 4 of this test case created by Kyle Simpson

Preparation code

  var foo = 12,
      bar = 12,
      baz = "12";

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
Non-strict equal
foo == bar;
Strict equal
foo === bar;
different types, coercion
foo == baz;
different types, no coercion
foo === baz;

Compare results of other browsers


You can edit these tests or add even more tests to this page by appending /edit to the URL.

1 Comment

John-David Dalton commented :

By spec (here and here) both == and === should perform the same number of steps when comparing like type values.

The point of this test is to show that even though there are micro differences there is no real world performance concern for using === over == as the lowest ops/sec are still in the millions of operations a second. You should use the correct operator for the job.