Ternary tests (v3)

Revision 3 of this benchmark created on


Preparation HTML

<script>
  var context = {},
      tmp = [],
      i = 0;
  context.test = [];
  
  
  for (i = 0; i <= 10000; i++) {
    context.test[0] = i;
  }
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
ternary
tmp = ((typeof context.test !== 'undefined') ? context.test : 'blah');
ready
simple condition
if (typeof context.test !== 'undefined') {
  tmp = context.test;
} else {
  tmp = 'blah';
}
ready
simple condition without brace
if (typeof context.test !== 'undefined')
  tmp = context.test;
else
  tmp = 'blah';
ready

Revisions

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