Test name | Executions per second |
---|---|
spread operator | 9755999.0 Ops/sec |
unshift | 7921735.5 Ops/sec |
push reverse | 9931914.0 Ops/sec |
var arr = [
{
"opportunityId": 5943111,
"findingList": [
{
"findingId": 6919
}
],
},
{
"opportunityId": 5943111,
"findingList": [
{
"findingId": 6918,
"findingId": 6917
}
]
}
]
arr.reduce((acc, findingInOpp) => [findingInOpp.findingList.map(({ findingId }) => findingId), acc],[])
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
},[])
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()