Skip to content

Commit d7b8211

Browse files
committed
docs: reframe arrow function guidance around recommended use cases
1 parent 74054f5 commit d7b8211

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

README.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -949,15 +949,18 @@ Other Style Guides
949949

950950
> Why not? If you have a fairly complicated function, you might move that logic out into its own named function expression.
951951

952-
> **Note:** While arrow functions are recommended for anonymous callbacks, traditional
953-
> function declarations or expressions are still preferred in certain scenarios where
954-
> their behavior is more appropriate.
952+
> **Note:** Arrow functions are intended primarily for short, anonymous callbacks.
953+
> Outside of these cases, prefer traditional function declarations or expressions
954+
> for clarity and consistency.
955955
>
956-
> **Prefer traditional functions when:**
956+
> **Use arrow functions only when:**
957957
>
958-
> - You are defining top-level, reusable functions rather than inline callbacks.
959-
> - You need a **dynamic `this` binding**, for example in object methods or DOM event handlers.
960-
> - You require access to the **`arguments` object**, which is not available in arrow functions.
958+
> - Defining inline callbacks (for example in `map`, `filter`, or event handlers).
959+
> - A lexical `this` binding is explicitly desired.
960+
>
961+
> In other situations — such as defining reusable functions, object methods, or code
962+
> that relies on a dynamic `this` value or the `arguments` object — prefer traditional
963+
> functions.
961964
>
962965
> **Examples:**
963966
>
@@ -986,6 +989,7 @@ Other Style Guides
986989
987990
988991
992+
989993
```javascript
990994
// bad
991995
[1, 2, 3].map(function (x) {

0 commit comments

Comments
 (0)