Boolean filter (v4)

Revision 4 of this benchmark created on


Preparation HTML

<script>
let array = [0, 1, false, 2, '', 3, null, 'a', undefined, NaN, 'b'];
</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 of
const out = [];
for(const value of array) if(value) out.push(value);
ready
for loop
const out = [];
for(let i=0 ; i<array.length ; i++) if(array[i]) out.push(array[i]);
ready

Revisions

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