
The Hidden Cost of Object Spread
Short summary
Object spread syntax in JavaScript creates a full shallow copy of every property on every invocation, which can degrade performance significantly when applied to large objects or inside reduce loops where it approaches O(n²) complexity. The article demonstrates that for small objects spread is fine and readable, but for large state trees, frequent reducers, or nested updates, alternatives like mutable loops, state normalization, or Immer are preferable. The key takeaway is that spread cost is contextual—developers should understand the allocation and garbage-collection implications rather than assuming spread is always fast or always slow.
- •Object spread copies every property each time, creating hidden O(n²) patterns in reduce loops
- •For small objects spread is fine; for large state trees or hot paths use loops, Immer, or state normalization
- •Every spread allocates temporary objects that increase garbage-collection pressure in high-frequency update scenarios
Generated with AI, which can make mistakes.
Is this a good recommendation for you?



