eqeqeq vs eq

JavaScript performance comparison

Revision 4 of this test case created by Mike McCaughan

Info

Check performance of === vs == in varying situations.

Preparation code

<script>
  var u, e = '',
  isU = function (v) { return typeof v === 'undefined'; },
  isN = function (v) { return v === null; },
  isUN = function (v) { return typeof v !== 'undefined' && v !== null; },
  isUNfn = function (v) { return !isU(v) && !isN(v); },
  isUNb = function (v) { return !!!v; };
</script>

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
u eqeqeq undefined
if (u === undefined) {
 e = '';
}
pending…
u eqeq undefined
if (u == undefined) {
 e = '';
}
pending…
typeof u eqeqeq 'undefined'
if (typeof u === 'undefined') {
 e = '';
}
pending…
typeof u eqeq 'undefined'
if (typeof u == 'undefined') {
 e = '';
}
pending…
isU
if (isU(u)) {
 e = '';
}
pending…
isN
if (isN(u)) {
 e = '';
}
pending…
isUN
if (isUN(u)) {
 e = '';
}
pending…
isUNfn
if (isUNfn(u)) {
 e = '';
}
pending…
isUNb
if (isUNb(u)) {
 e = '';
}
pending…
u
if (u) {
e = '';
}
pending…
not u
if (!u) {
e = '';
}
pending…
not not u
if (!!u) {
e = '';
}
pending…
not not not u
if (!!!u) {
e = '';
}
pending…

Compare results of other browsers

Revisions

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:

0 comments

Add a comment