Comparison of comparisons

JavaScript performance comparison

Test case created by minitech


Compares the performance of == and ===.

Preparation code

Benchmark.prototype.setup = function() {
    var a = 'hello';
    var b = 'world';
    var c = 'hello';

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
a === b;
a === c;
a == b;
a == c;

Compare results of other browsers


You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:


Ben commented :

Identity is infinitely faster than equality. Checkout my results for proof.

billy commented :

Agreed with Ben, chrome will optimize this.

Lonesome Walker commented :

fyi in ie9:

Identity a === b; a === c; 20,206,844 ±0.23%25% slower

Equality a == b; a == c; 27,134,240 ±0.68%fastest

Well, my firefox says: Identity a === b; a === c; 819,540,161 ±0.26%fastest

Equality a == b; a == c; 38,048,899 ±0.50%95% slower

So, it depends ;)

Tim Down commented :

Clearly it varies with browser. Since these particular comparisons are defined by the ECMAScript spec to run precisely the same steps, this is an unsurprising result: it's bound to be engine-dependent.

Jordan commented :

I love how BlackBerry WebKit managed to be faster than anything else using ===...

Add a comment