to boolean vs comparison (v2)

Revision 2 of this benchmark created on


Setup

var result;
    
    var convert = function (value) {
        return !!value;
    };
    
    var compare = function (value) {
        return value === 1;
    };
    
    var compare2 = function (value) {
        return value == 1;
    };

Test runner

Ready to run.

Testing in
TestOps/sec
to boolean
result = convert(1);
result = convert(0);
ready
comparison (===)
result = compare(1);
result = compare(0);
ready
comparison (==)
result = compare2(1);
result = compare2(0);
ready

Revisions

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