From 650070a8defe786c0f5f6776333b4a59ed265411 Mon Sep 17 00:00:00 2001 From: Hoarfroster Date: Thu, 13 Jun 2024 15:03:33 +0800 Subject: [PATCH] feat: improvements on glossary Argument & Parameter (#34102) * feat: improvements on glossary Argument & Parameter * revert: parameters versus arguments * revert: link * feat: improvements Co-authored-by: Joshua Chen --------- Co-authored-by: Joshua Chen --- files/en-us/glossary/argument/index.md | 9 ++++++--- files/en-us/glossary/parameter/index.md | 21 +++++++++++++-------- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/files/en-us/glossary/argument/index.md b/files/en-us/glossary/argument/index.md index 5a1c4119ab6d4bd..b74be64790c9dd1 100644 --- a/files/en-us/glossary/argument/index.md +++ b/files/en-us/glossary/argument/index.md @@ -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: @@ -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"; @@ -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")}} diff --git a/files/en-us/glossary/parameter/index.md b/files/en-us/glossary/parameter/index.md index eeacf7435390e44..c11c53e71c4ffea 100644 --- a/files/en-us/glossary/parameter/index.md +++ b/files/en-us/glossary/parameter/index.md @@ -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: @@ -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_]() - [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")}}