Boolean conversion speed (v6)

Revision 6 of this benchmark created 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
AND true
var c;
for(var idx=0; idx < a.length; ++a) {
    c = a[idx] && true;
}
ready

Revisions

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