Tuesday 24 July 2018

Mutation vs. Object copying server side

So normally I really hate to do mutation of objects because it can be a good way to cause weird errors. However, for a node service which could get getting lots of requests a second, it seems like deeply copying an object to make changes could have performance implications. Any thoughts on this practice server side?Ex:const thing = getThing (); thing.other.deep.prop = 'mutated'; Vs.const thing = getThing (); const newThing = { ...thing, other: { ...thing.other, deep: { ...thing.other.deep, prop: 'not mutated' }, }, };

Submitted July 24, 2018 at 07:13PM by mikejoro

No comments:

Post a Comment