Skip to content

Confusing use of "function declaration" in describing default parameters #3509

@senocular

Description

@senocular

Alternative default parameters
Sometimes it makes sense to assign default values for parameters at a later stage after the function declaration.
...

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions