ternary vs. logical op

Benchmark created on


Preparation HTML

<script>
  var a = true,
      b = false,
      c = 1,
      d = 2;
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
ternary (true)
var e = a ? c : d;
ready
ternary (false)
var e = b ? c : d;
ready
logical (true)
var e = a && c || d;
ready
logical (false)
var e = b && c || d;
ready

Revisions

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