let arr = []; items.forEach(item => { arr.push({ ... }); }); return arr;

or…

return items.map(item => ({ ... }));

Guess which one MastoFE does?

Follow

@alex In defence of the first one it's often easier to read.

@valleyforge I think it’s harder. When I see let arr = [] I wonder “when is this going to be modified, and how?” Using a functional approach like map you don’t have to wonder.

Sign in to participate in the conversation
CleverLibre Social

CleverLibre Social is an inclusive social instance for open discussion, learning, and community.
All cultures welcome.
Hate speech and harassment strictly forbidden.