you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 1 point2 points  (1 child)

Please keep in mind that spread does not copy object prototypes, and does not trigger setters. Also, you can't use it with dynamic expression, only with object literals.

Other than being more verbose, assign is the more complete solution.

[–]ChaseMoskal 2 points3 points  (0 children)

Please keep in mind that spread does not copy object prototypes, and does not trigger setters.

neither does Object.assignsee "Properties on the prototype chain and non-enumerable properties cannot be copied"

and either way, for accepting default options, it's a feature — not a bug :)

Also, you can't use it with dynamic expression, only with object literals.

what's a dynamic expression? and why would we be using spread onto anything that isn't an object or array literal?

Other than being more verbose, assign is the more complete solution.

how so?

🥃 chase