is undefined

Benchmark created by Don on


Preparation HTML

<script>
  var undef, undef2, count=0;
  function isUndefined1 (x) {
      return x === undefined;
  }
  function isUndefined2 (x) {
      return typeof undef === 'undefined';
  }
  function isUndefined3 (x) {
      return typeof x == 'undefined';
  }
  function isUndefined4 (x) {
      return x === undef2;
  }
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
strict eq undefined
if (undef === undefined) {
    ++count;
}
ready
typeof strict eq undefined
if (typeof undef === 'undefined') {
    ++count;
}
ready
typeof eq undefined
if (typeof undef == 'undefined') {
    ++count;
}
ready
strict eq undef var
if (undef === undef2) {
    ++count;
}
ready
isUndefined1
if (isUndefined1(undef)) {
    ++count;
}
ready
isUndefined2
if (isUndefined2(undef)) {
    ++count;
}
ready
isUndefined3
if (isUndefined3(undef)) {
    ++count;
}
ready
isUndefined4
if (isUndefined4(undef)) {
    ++count;
}
ready

Revisions

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

  • Revision 1: published by Don on
  • Revision 2: published by Nige White on