ChatGPT解决这个技术问题 Extra ChatGPT

"Parameter" vs "Argument" [duplicate]

This question already has answers here: What's the difference between an argument and a parameter? (37 answers) Arguments or parameters? [duplicate] (12 answers) Closed 2 years ago.

I got parameter and argument kind of mixed up and did not really pay attention to when to use one and when to use the other.

Can you please tell me?

In Russian "parameters" are called "formal parameters", while "arguments" are called "actual parameters".
We use this convention italian as well.
I like this quote from MSDN: "...the procedure defines a parameter, and the calling code passes an argument to that parameter. You can think of the parameter as a parking space and the argument as an automobile."
argument is the one you use it, while parameter is a blank to be filled in.
We pass argument(s) while calling a function and the function receives as parameter(s).

R
Rory O'Kane

A parameter is the variable which is part of the method’s signature (method declaration). An argument is an expression used when calling the method.

Consider the following code:

void Foo(int i, float f)
{
    // Do things
}

void Bar()
{
    int anInt = 1;
    Foo(anInt, 2.0);
}

Here i and f are the parameters, and anInt and 2.0 are the arguments.


Old post, but another way of saying it: argument is the value/variable/reference being passed in, parameter is the receiving variable used w/in the function/block.
Or, a method has parameters and takes arguments.
Someday I will explode and it will be a shower of developer's lingo.
Why is it that within JavaScript, when you want to access the parameters of a function/method, you have to access the "arguments" variable? Shouldn't that be "parameters" instead?
@ngDeveloper Nope, it should be arguments. You get access to the list of argument values passed to the function. Consequently you don't get a list of the parameter names of the function, javascript doesn't give you a way to get that info.