Tests:
  • spread operator

    x
     
    var arr = [
            {
                "opportunityId": 5943111,
                "findingList": [
                    {
                        "findingId": 6919
                         }
                    ],
              },
              {
                    "opportunityId": 5943111,
                "findingList": [
                    {
                        "findingId": 6918,
                               "findingId": 6917
                         }
                    ]
              }
    ]
    arr.reduce((acc, findingInOpp) => [...findingInOpp.findingList.map(({ findingId }) => findingId), ...acc],[])
  • unshift

     
    var arr = [
            {
                "opportunityId": 5943111,
                "findingList": [
                    {
                        "findingId": 6919
                         }
                    ],
              },
              {
                    "opportunityId": 5943111,
                "findingList": [
                    {
                        "findingId": 6918,
                               "findingId": 6917
                         }
                    ]
              }
    ]
    arr.reduce((acc, findingInOpp) => {
        acc.unshift(...findingInOpp.findingList.map(({ findingId }) => findingId))
        return acc
    },[])
  • push reverse

     
    var arr = [
            {
                "opportunityId": 5943111,
                "findingList": [
                    {
                        "findingId": 6919
                         }
                    ],
              },
              {
                    "opportunityId": 5943111,
                "findingList": [
                    {
                        "findingId": 6918,
                               "findingId": 6917
                         }
                    ]
              }
    ]
    arr.reduce((acc, findingInOpp) => {
        acc.push(...findingInOpp.findingList.map(({ findingId }) => findingId))
        return acc
    },[]).reverse()
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    spread operator
    unshift
    push reverse

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 4 months ago)
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36
Chrome 127 on Mac OS X 10.15.7
View result in a separate tab
Test name Executions per second
spread operator 9755999.0 Ops/sec
unshift 7921735.5 Ops/sec
push reverse 9931914.0 Ops/sec