eqeqeq vs eq (v7)

Revision 7 of this benchmark created by Mike McCaughan on


Description

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

Preparation HTML

<script>
  var u, n = null,
      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
n eqeqeq null
if (n === null) {
  e = '';
}
ready
n eqeq null
if (n == null) {
  e = '';
}
ready
isU
if (isU(n)) {
  e = '';
}
ready
isN
if (isN(n)) {
  e = '';
}
ready
isUN
if (isUN(n)) {
  e = '';
}
ready
isUNfn
if (isUNfn(n)) {
  e = '';
}
ready
isUNb
if (isUNb(n)) {
  e = '';
}
ready
n
if (n) {
  e = '';
}
ready
not n
if (!n) {
  e = '';
}
ready
not not n
if ( !! n) {
  e = '';
}
ready
not not not n
if ( !! !n) {
  e = '';
}
ready
u eqeqeq null
if (u === null) {
  e = '';
}
ready
u eqeq null
if (u == null) {
  e = '';
}
ready
u isU
if (isU(u)) {
  e = '';
}
ready
u isN
if (isN(u)) {
  e = '';
}
ready
u isUN
if (isUN(u)) {
  e = '';
}
ready
u isUNfn
if (isUNfn(u)) {
  e = '';
}
ready
u 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