eqeqeq vs eq (v4)

Revision 4 of this benchmark created by Mike McCaughan on


Description

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

Preparation HTML

<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

Ready to run.

Testing in
TestOps/sec
u eqeqeq undefined
if (u === undefined) {
 e = '';
}
ready
u eqeq undefined
if (u == undefined) {
 e = '';
}
ready
typeof u eqeqeq 'undefined'
if (typeof u === 'undefined') {
 e = '';
}
ready
typeof u eqeq 'undefined'
if (typeof u == 'undefined') {
 e = '';
}
ready
isU
if (isU(u)) {
 e = '';
}
ready
isN
if (isN(u)) {
 e = '';
}
ready
isUN
if (isUN(u)) {
 e = '';
}
ready
isUNfn
if (isUNfn(u)) {
 e = '';
}
ready
isUNb
if (isUNb(u)) {
 e = '';
}
ready
u
if (u) {
e = '';
}
ready
not u
if (!u) {
e = '';
}
ready
not not u
if (!!u) {
e = '';
}
ready
not not not u
if (!!!u) {
e = '';
}
ready

Revisions

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

  • Revision 1: published on
  • Revision 2: published on
  • Revision 3: published by Mike McCaughan on
  • Revision 4: published by Mike McCaughan on
  • Revision 5: published by Mike McCaughan on
  • Revision 6: published by Mike McCaughan on
  • Revision 7: published by Mike McCaughan on
  • Revision 8: published on