Run details:
Mozilla/5.0 (Linux; Android 11; SM-N975U) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.104 Mobile Safari/537.36
Chrome Mobile 96
Android
Mobile
3 years ago
Test name Executions per second
filter map speed 120.9 Ops/sec
flatMap speed 24.0 Ops/sec
Script Preparation code:
x
 
var arr = [];
var i = 0;
while (i <= 1E5) arr[i] = i++;
Tests:
  • filter map speed

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

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