if vs || (v2)

Revision 2 of this benchmark created on


Preparation HTML

<script>
  var exists = "exists";
  var undef = undefined;
  var value = "value";
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
If (value undefined)
if (!undef) undef = value;
ready
If (value defined)
if (!exists) exists = value;
ready
|| (value undefined)
undef = undef || value;
ready
|| (value defined)
exists = exists || value;
ready
? operator
exists ? exists : exists = value;
ready

Revisions

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

  • Revision 1: published by Adrian Sutton on
  • Revision 2: published on