Ternary Operator

Benchmark created on


Preparation HTML

<script>
  var context = {
    'test': []
  };
  for (var i = 0; i < 100000; i++) {
    context['test'][i] = i;
  }
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
snippet 1
for (var i = 0, tmp; i < 100; i++) {
  tmp = (context['test']) ? context['test'] : '';
}
ready
snippet 2
for (var i = 0, tmp; i < 100; i++) {
  if (context['test']) {
    tmp = context['test'];
  } else {
    tmp = '';
  }
}
ready

Revisions

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