ternary operator vs. if statement

Benchmark created by Yannick Albert on


Test runner

Ready to run.

Testing in
TestOps/sec
ternary operator
"ontouchstart" in window ? alert(true) : alert(false);
ready
if statement
if ("ontouchstart" in window) {alert(true);} else {alert(false);}
ready

Revisions

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