javascript-tutorial / javascript-tutorial/en.javascript.info

Confusing use of "function declaration" in describing default parameters

Open
#3,509 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
HTML
Stars
25.5k
Forks
4k
PR merge metrics
No merged PRs in 30d

Description

> **[Alternative default parameters](https://javascript.info/function-basics#alternative-default-parameters)**
> Sometimes it makes sense to assign default values for parameters at a later stage after the function declaration.
> ...
> ```js run
> function showMessage(text) {
> // ...
>
> if (text === undefined) { // if the parameter is missing
> text = 'empty message';
> }
>
> alert(text);
> }
>
> showMessage(); // empty message
> ```

The declaration includes the function definition. Saying "after the function declaration" suggests something happening after the entirety of the function when the description refers to something happening later in the body.

Contributor guide

No contributing guide indexed for this repository

Research direction

Open the linked Alternative default parameters section and review the wording around the example. Revise the reference to "function declaration" so it accurately describes the later assignment inside the function body, then check that the surrounding explanation remains clear.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
documentation
Issue type
Documentation
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.