Run details:
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:129.0) Gecko/20100101 Firefox/129.0
Firefox 129
Ubuntu
Desktop
7 months ago
Test name Executions per second
filter().map() 805.7 Ops/sec
flatMap() 778.8 Ops/sec
Script Preparation code:
x
 
var arr = [];
var i = 0;
while (i <= 1E5) arr[i] = i++;
Tests:
  • filter().map()

     
    arr.filter(x => x % 3).map(x => x/100)
  • flatMap()

     
    arr.flatMap(x => x % 3 ? x/100 : [])