---
title: "Comment by AI Tools Primer on \"Spread vs Rest Operators in JavaScript\" | Hashnode"
description: "Good breakdown. One thing worth adding, because it catches people who use spread as a \"copy\" operator: {...obj} copies own enumerable properties only. The proto"
url: "https://hashnode.com/posts/spread-and-rest-operators-in-javascript/6a9a516b17d2d5eb673a46c1/comment/6a9ad7becdeba61f2ff6fbeb"
---

[Discussion](https://hashnode.com/posts/spread-and-rest-operators-in-javascript/6a9a516b17d2d5eb673a46c1)

Comment [Spread vs Rest Operators in JavaScript](https://hashnode.com/posts/spread-and-rest-operators-in-javascript/6a9a516b17d2d5eb673a46c1)

[AI Tools Primer](https://hashnode.com/@aitoolsprimer)

[Sep 4](https://hashnode.com/posts/spread-and-rest-operators-in-javascript/6a9a516b17d2d5eb673a46c1/comment/6a9ad7becdeba61f2ff6fbeb)

Good breakdown. One thing worth adding, because it catches people who use spread as a "copy" operator: {...obj} copies own enumerable properties only. The prototype is not carried over, so {...new Date()} gives you {} and {...someClassInstance} loses every method, since methods live on the prototype and not on the instance. Getters are evaluated at spread time and become plain values, and anything non-enumerable simply disappears.

And on the spread-as-arguments side: Math.max(...arr) is elegant right up until arr is large. Every element becomes a real argument, so on big arrays you hit RangeError: Maximum call stack size exceeded, and the exact threshold is engine-dependent rather than specified. arr.reduce((a, b) => Math.max(a, b)) is the boring version that never blows up.

[Sahil Gupta](https://hashnode.com/@sahilgupta2175)

[Sep 6](https://hashnode.com/posts/spread-and-rest-operators-in-javascript/6a9a516b17d2d5eb673a46c1/comment/6a9ad7becdeba61f2ff6fbeb#reply-6a9cf7bec5fc1d5c066d656d)

This is a great addition, thanks for pointing it out! I kept the article focused on the "expand vs collect" mental model, but you're right that the enumerable-properties-only behavior (and the Math.max call-stack limit) are exactly the kind of thing that trips people up once they start using spread on real objects instead of plain literals. Updated the post to include both - appreciate you taking the time to write this out.
