diff --git a/README.md b/README.md index c41183af..43ce70db 100644 --- a/README.md +++ b/README.md @@ -556,21 +556,7 @@ Other Style Guides } ``` - - [7.8](#7.8) Always put default parameters last. - - ```javascript - // bad - function handleThings(opts = {}, name) { - // ... - } - - // good - function handleThings(name, opts = {}) { - // ... - } - ``` - - - [7.9](#7.9) Avoid side effects with default parameters. + - [7.8](#7.8) Avoid side effects with default parameters. > Why? They are confusing to reason about. @@ -586,6 +572,20 @@ Other Style Guides count(); // 3 ``` + - [7.9](#7.9) Always put default parameters last. + + ```javascript + // bad + function handleThings(opts = {}, name) { + // ... + } + + // good + function handleThings(name, opts = {}) { + // ... + } + ``` + - [7.10](#7.10) Never use the Function constructor to create a new function. > Why? Creating a function in this way evaluates a string similarly to eval(), which opens vulnerabilities.