Boolean conversion speed

Benchmark created by PhilH on


Setup

var a = [0,1,"","tt",false,true,"true","false",undefined,-0,null,NaN,new Boolean(true),new Boolean(false)];

Test runner

Ready to run.

Testing in
TestOps/sec
Bang bang
var b;
for(var idx=0; idx < a.length; ++a) {
    b = !!a[idx];
}    
ready
Boolean function
var b;
for(var idx=0; idx < a.length; ++a) {
    b = Boolean(a[idx]);
}
ready

Revisions

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