Try/Catch Error Perf (v71)

Revision 71 of this benchmark created on


Preparation HTML

<script>
  function tryCatch(undef) {
    try {
      return 123;
    } catch (ex) {
      return null;
    }
  }

  function ifUndefinedCheck(undef) {
    if (123 !== undefined) {
      return 123;
    } else {
      return null;
    }
  }
function ifTypeofCheck(undef) {
    if (typeof 123 !== 'undefined') {
      return 123;
    } else {
      return null;
    }
  }

function ifCheckExists(undef) {
    if (123) {
      return 123;
    } else {
      return null;
    }
  }

function ifCheckTernary() {
    return 123 ? 123 :null;
  }
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Try Catch
tryCatch({});
ready
If Undefined Check
ifUndefinedCheck({});
ready
If Typeof Check
ifTypeofCheck({});
ready
If Exists Check
ifCheckExists({});
ready
Ternary Check
ifCheckTernary({});
ready

Revisions

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