eqeqeq vs eq
JavaScript performance comparison
Info
Check performance of === vs == in varying situations.
Preparation code
<script>
var u = undefined,
i = 0,
a = "0",
n = null,
e = '',
isU = function (v) { return typeof u === 'undefined'; },
isN = function (v) { return u === null; },
isUN = function (v) { return typeof u !== 'undefined' && u !== 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.
| Test | Ops/sec | |
|---|---|---|
u eqeqeq undefined |
|
pending… |
u eqeq undefined |
|
pending… |
typeof u eqeqeq 'undefined' |
|
pending… |
typeof u eqeq 'undefined' |
|
pending… |
i eqeqeq 0 |
|
pending… |
i eqeq 0 |
|
pending… |
i eqeqeq '0' |
|
pending… |
i eqeq '0' |
|
pending… |
a eqeqeq 0 |
|
pending… |
a eqeq 0 |
|
pending… |
a eqeqeq '0' |
|
pending… |
a eqeqeq '0' |
|
pending… |
n eqeqeq null |
|
pending… |
n eqeq null |
|
pending… |
n eqeqeq 0 |
|
pending… |
e eqeqeq '' |
|
pending… |
e eqeq '' |
|
pending… |
e.length eqeqeq 0 |
|
pending… |
e.length eqeqeq 0 |
|
pending… |
e.length !eqeq 0 |
|
pending… |
e.length !eq 0 |
|
pending… |
e.length |
|
pending… |
u |
|
pending… |
not u |
|
pending… |
not not u |
|
pending… |
not not not u |
|
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:
- Revision 1: published
- Revision 2: published
- Revision 3: published by Mike McCaughan
- Revision 4: published by Mike McCaughan
- Revision 5: published by Mike McCaughan
- Revision 6: published by Mike McCaughan
- Revision 7: published by Mike McCaughan
- Revision 8: published
0 comments