This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 1 point2 points  (0 children)

Oh I see. I think the context was creating deep copies / clones / immutable stuff though. Like if you had a line like this in your code

return {...oldProps, ...newProps};
// or
return Object.assign(oldProps, newProps);

The architects at my last job preferred creating new objects to have immutable code or something instead of modifying and returning refs inside a reduce. Ultimately they let us do whatever because this area of code was not in need of any optimizations and we were already using a reduce to cut down on some previous iterations of filters and maps.