Script Preparation code:
Tests:

Historical Performance Data aggregated from 24 community runs

Desktop Results:
Chrome 16 runs
foreach & push
903/s
flatMap()
615/s
filter().map()
542/s

Fastest: foreach & push (1.7x faster)

View exact numbers
  • foreach & push: 903 ops/sec
  • flatMap(): 615 ops/sec
  • filter().map(): 542 ops/sec
Firefox 8 runs
foreach & push
1K/s
filter().map()
776/s
flatMap()
702/s

Fastest: foreach & push (1.6x faster)

View exact numbers
  • foreach & push: 1,106 ops/sec
  • filter().map(): 776 ops/sec
  • flatMap(): 702 ops/sec

Results show median performance across all community submissions. Run this benchmark yourself to verify on your device.

Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results
  • Test case name Result
    filter().map()
    flatMap()
    foreach & push

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 5 months ago)
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:148.0) Gecko/20100101 Firefox/148.0
Firefox 148 on Windows
View result in a separate tab
foreach & push
1K/s
filter().map()
773/s
flatMap()
681/s
View exact numbers
Test name Executions per second
foreach & push 1,127 Ops/sec
filter().map() 773 Ops/sec
flatMap() 681 Ops/sec