If not vs or

Benchmark created by James Brumond on


Preparation HTML

<script>
  var truthy = 1;
  var falsey = 0;
  
  var assign = 2;
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
If not falsey
(function(a) {
  if (! a) {
    a = assign;
  }
}(falsey));
ready
If not truthy
(function(a) {
  if (! a) {
    a = assign;
  }
}(truthy));
ready
Falsey or
(function(a) {
  a = a || assign;
}(falsey));
ready
Truthy or
(function(a) {
  a = a || assign;
}(truthy));
ready

Revisions

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

  • Revision 1: published by James Brumond on