Boolean filter (v3)

Revision 3 of this benchmark created on


Preparation HTML

<script>
let array = Array.from({"length": 500000}, (_, i) => Math.round(Math.random()))
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Boolean upcast
array.filter(Boolean);
ready
Double false operator
array.filter(value => !!value)
ready
For loop
(function(){
    let ret = [];
    for(var i=0;i<array.length;i++){
        if(!!array[i]){
            ret.push(array[i]);
        }
    }
    return ret;
})()
ready

Revisions

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