Boolean conversion speed (v3)

Revision 3 of this benchmark created by x3cion on


Preparation HTML

<script>
a = [0, 1, "", "tt", false, true, "true", "false", undefined, -0, null, NaN, new Boolean(true), new Boolean(false)];
b = false;
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Bang bang
var i = a.length;
while(i--){
  b = !! a[i];
}
ready
Boolean function
var i = a.length;
while(i--){
  b = Boolean(a[i]);
}
ready

Revisions

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