boolean vs notnot vs truthy

JavaScript performance comparison

Test case created by Thomathan

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  var f1 = '';
  var f2 = 0;
  var f3 = false;
  
  var t1 = 'asdf';
  var t2 = 999;
  var t3 = true;
  

};
</script>

Test runner

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

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
Boolean
Boolean(t1) && Boolean(t2) && Boolean(t3) && (Boolean(f1) || Boolean(f2) ||Boolean(f3))
pending…
not-not
!!t1 && !!t2 && !!t3 && (!!f1 || !!f2 || !!f3)
pending…
truthy
t1 && t2 && t3 && (f1 || f2 || f3)
pending…
truthy-single
if (f1) {
}
pending…
notnot-single
if (!!f1) {
}
pending…
Boolean-single
if (Boolean(f1)) {
}
pending…

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

0 Comments