Skip to content

Commit

Permalink
feat: improvements on glossary Argument & Parameter (#34102)
Browse files Browse the repository at this point in the history
* feat: improvements on glossary Argument & Parameter

* revert: parameters versus arguments

* revert: link

* feat: improvements

Co-authored-by: Joshua Chen <[email protected]>

---------

Co-authored-by: Joshua Chen <[email protected]>
  • Loading branch information
PassionPenguin and Josh-Cena committed Jun 13, 2024
1 parent 864f91f commit 650070a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
9 changes: 6 additions & 3 deletions files/en-us/glossary/argument/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ page-type: glossary-definition

{{GlossarySidebar}}

An **argument** is a {{glossary("value")}} ({{Glossary("primitive")}} or {{Glossary("object")}}) passed as input to a {{Glossary("function")}}.
**Arguments** are {{glossary("value", "values")}} ({{Glossary("primitive")}} or {{Glossary("object")}}) passed as input to a {{Glossary("function")}}. Do not confuse arguments with {{Glossary("parameter","parameters")}}, which are the names used in the function definition to refer to the arguments.

For example:

Expand All @@ -22,7 +22,7 @@ function example(parameter1, parameter2) {
}
```

The argument order within the function call should be the same as the {{Glossary("parameter","parameters")}} order in the function definition.
The argument order within the function call should be the same as the parameters order in the function definition.

```js
const argument1 = "foo";
Expand All @@ -38,4 +38,7 @@ function example(parameter) {
## See also

- [Difference between parameter and argument](/en-US/docs/Glossary/Parameter#parameters_versus_arguments)
- The {{jsxref("Functions/arguments","arguments")}} object in {{glossary("JavaScript")}}
- The {{jsxref("Functions/arguments", "arguments")}} object in {{glossary("JavaScript")}}
- Glossary
- {{Glossary("Function")}}
- {{Glossary("Parameter")}}
21 changes: 13 additions & 8 deletions files/en-us/glossary/parameter/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,20 @@ page-type: glossary-definition

{{GlossarySidebar}}

A parameter is a named variable passed into a {{Glossary("function")}}. Parameter variables are used to import {{Glossary("argument","arguments")}} into functions.
**Parameters** are named variables declared as part of a {{Glossary("function")}}. They are used to reference the {{Glossary("argument", "arguments")}} passed into the function.

For example:

```js
function example(parameter) {
console.log(parameter); // Output = foo
const argument1 = "Web";
const argument2 = "Development";
example(argument1, argument2); // passing two arguments

// This function takes two values
function example(parameter1, parameter2) {
console.log(parameter1); // Output = "Web"
console.log(parameter2); // Output = "Development"
}

const argument = "foo";

example(argument);
```

There are two kinds of parameters:
Expand All @@ -37,6 +39,9 @@ Note the difference between _parameters_ and _arguments_:

## See also

- [Difference between _parameter_ and _argument_](https://en.wikipedia.org/wiki/Parameter_%28computer_programming%29#Parameters_and_arguments) on Wikipedia
- [Difference between _parameters_ and _arguments_](<https://en.wikipedia.org/wiki/Parameter_(computer_programming)#Parameters_and_arguments>)
- [Function declaration](/en-US/docs/Web/JavaScript/Reference/Statements/function)
- [Function expression](/en-US/docs/Web/JavaScript/Reference/Operators/function)
- Glossary
- {{Glossary("Function")}}
- {{Glossary("Argument")}}

0 comments on commit 650070a

Please sign in to comment.