javascript-tutorial / javascript-tutorial/en.javascript.info
Confusing use of "function declaration" in describing default parameters
- 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