Run details:
Mozilla/5.0 (X11; CrOS x86_64 14541.0.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36
Chrome 126
Chrome OS 14541.0.0
Desktop
one month ago
Test name Executions per second
Functional 33453.0 Ops/sec
Imperative 231100.0 Ops/sec
Script Preparation code:
AخA
 
window.nums = new Array(1000).fill(0).map((x,i) => i)
Tests:
  • Functional

    x
     
    const y = nums.filter(x => x%2).map(x => x*3).filter(x => x < 100)
    return y
  • Imperative

     
    const y = []
    for(const x of nums) {
      if(x%2) {
        const x3 = x*3;
        if(x3 < 100) {
          y.push(x3)
        }
      }
    }
    return y