Scotch Falsy Bouncer

JavaScript performance comparison

Test case created by worldclassdev

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  // USING A FOR OF LOOP
  
  function falsyBouncerForOf(array) {
      let result =[]
      
      for (value of array){
          if(value){
              result.push(value)
          }
      }
      
      return result
  }
  
  // USING .FILTER()
  
  function falsyBouncerFilter(array) {
      return array.filter((value) =>{
        return Boolean(value)  
      })
  }
  
  

};
</script>

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
Using a for...of loop
falsyBouncerForOf([NaN, 0, null, '', undefined])
pending…
Using .filter()
falsyBouncerFilter([NaN, 0, null, '', undefined])
pending…

Compare results of other browsers

Revisions

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

0 Comments