Skip to content

Commit 74054f5

Browse files
committed
docs: align arrow function guidance with non-inline usage
1 parent 005116e commit 74054f5

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

README.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -955,18 +955,16 @@ Other Style Guides
955955
>
956956
> **Prefer traditional functions when:**
957957
>
958-
> - You rely on **function hoisting**, such as calling a function before its definition.
958+
> - You are defining top-level, reusable functions rather than inline callbacks.
959959
> - You need a **dynamic `this` binding**, for example in object methods or DOM event handlers.
960960
> - You require access to the **`arguments` object**, which is not available in arrow functions.
961961
>
962962
> **Examples:**
963963
>
964964
> ```js
965-
> // Function hoisting
966-
> initialize();
967-
>
968-
> function initialize() {
969-
> // setup logic
965+
> // Named function for reuse and clearer stack traces
966+
> function formatUserName(user) {
967+
> return `${user.firstName} ${user.lastName}`;
970968
> }
971969
> ```
972970
>

0 commit comments

Comments
 (0)