Skip to content
Closed

[spam] #2991

Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,14 @@ Other Style Guides

// good
const original = { a: 1, b: 2 };
const copy = { ...original, c: 3 }; // copy => { a: 1, b: 2, c: 3 }
const copy = { ...original, c: 3 }; // copy => { a: 1, b: 2, c: 3 } unsuitable for nested object

const { a, ...noA } = copy; // noA => { b: 2, c: 3 }

// best
const original = { a: 1, b: 2 };
// structuredClone is a hypothetical function that deep clones an object
const copy = {...structuredClone(original), c: 3}; // copy => { a: 1, b: 2, c: 3 }

const { a, ...noA } = copy; // noA => { b: 2, c: 3 }
```
Expand Down