Skip to content

Commit 4503a25

Browse files
authored
Add advantage in function parameters
1 parent 1c0b20a commit 4503a25

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,11 +251,12 @@ destructuring syntax. This has a few advantages:
251251

252252
1. When someone looks at the function signature, it's immediately clear what
253253
properties are being used.
254-
2. Destructuring also clones the specified primitive values of the argument
254+
2. It can be used to simulate named parameters.
255+
3. Destructuring also clones the specified primitive values of the argument
255256
object passed into the function. This can help prevent side effects. Note:
256257
objects and arrays that are destructured from the argument object are NOT
257258
cloned.
258-
3. Linters can warn you about unused properties, which would be impossible
259+
4. Linters can warn you about unused properties, which would be impossible
259260
without destructuring.
260261

261262
**Bad:**
@@ -264,6 +265,9 @@ destructuring syntax. This has a few advantages:
264265
function createMenu(title, body, buttonText, cancellable) {
265266
// ...
266267
}
268+
269+
createMenu("Foo", "Bar", "Baz", true);
270+
267271
```
268272

269273
**Good:**

0 commit comments

Comments
 (0)