v == 0 ? 1 : 0

JavaScript performance comparison

Test case created

Info

http://stackoverflow.com/questions/6911235/javascript-is-there-a-better-way-of-writing-v-v-0-1-0

Preparation code

<script>
  var v = 1;
</script>

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
v == 0 ? 1 : 0
v == 0 ? 1 : 0;
pending…
1 - v
1 - v;
pending…
v = +!v
+!v;
pending…
v ^= 1
v ^ 1;
pending…

Compare results of other browsers

Revisions

You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:

0 comments

Add a comment