Using forEach to push items onto a new array is almost always equivalent to using a map.
data.map(job => ({
title: job.title,
...
}))
The only case where it's not equivalent is if there's conditional logic in the body of the forEach callback which results in fewer or more elements in the new array than the original (in this case you can use reduce instead).
https://github.com/fac-13/jeth/blob/55aa475205ea69a649432a9c9cfd0b7e1854d083/src/logic.js#L4-L18
Using
forEach
topush
items onto a new array is almost always equivalent to using amap
.The only case where it's not equivalent is if there's conditional logic in the body of the
forEach
callback which results in fewer or more elements in the new array than the original (in this case you can usereduce
instead).