var keyword use

Benchmark created on


Setup

function in_array(what, where){
        var a = false, i = 0;
        for(;i < where.length;i++){
                if(what == where[i]){
                        a = true;
                        break;
                }
        }
        return a;
    }
    
    function in_array_(what, where){
        var a = false;
        for(var i = 0;i < where.length;i++){
                if(what == where[i]){
                        a = true;
                        break;
                }
        }
        return a;
    }
    
    var ar = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20];

Test runner

Ready to run.

Testing in
TestOps/sec
one var

in_array(20, ar);
ready
multiple var

in_array_(20, ar);
ready

Revisions

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