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
Qoto Mastodon

QOTO: Question Others to Teach Ourselves
An inclusive, Academic Freedom, instance
All cultures welcome.
Hate speech and harassment strictly forbidden.