Run details:
Mozilla/5.0 (X11; Linux x86_64; rv:134.0) Gecko/20100101 Firefox/134.0
Firefox 134
Linux
Desktop
22 days ago
Test name Executions per second
reduce with concat 0.7 Ops/sec
flatMap 1531.3 Ops/sec
Script Preparation code:
AخA
 
var arr = Array(10_000).fill(0)
Tests:
  • reduce with concat

     
    arr.reduce((acc, x) => [...acc, x, x], [])
  • flatMap

     
    arr.flatMap(x => [x, x])