0

I've read some things about the differences between parameters and arguments. And I saw the answer is: Function parameters are the names listed in the function definition. Function arguments are the real values passed to (and received by) the function. I'm wondering whether the above explainations are completed.

leminhnguyen
  • 1,518
  • 2
  • 13
  • 19
  • 1
    Yes, those are correct. This is not specific to JavaScript, it's general programming terminology. – Barmar Feb 28 '19 at 04:20
  • 1
    Possible duplicate of [What's the difference between an argument and a parameter?](https://stackoverflow.com/questions/156767/whats-the-difference-between-an-argument-and-a-parameter) and [Difference between parameter and argument](https://stackoverflow.com/questions/3176310) and [“Parameter” vs “Argument”](https://stackoverflow.com/questions/1788923) – adiga Feb 28 '19 at 04:30
  • This has [hundreds of duplicates](https://www.google.com/search?q=parameter+argument+difference+site:stackoverflow.com). Please read [How much research effort is expected of Stack Overflow users?](https://meta.stackoverflow.com/a/261593/3082296) – adiga Feb 28 '19 at 04:33

3 Answers3

4

Parameters are actually a method definition, it is a variables in that method whereas, an arguments are the data which you pass into parameters when method is called.

public void DemoMethod(string param) { }

string arg= "Argument example";
DemoClass.DemoMethod(arg);
Purvi Barot
  • 241
  • 2
  • 9
1

https://developer.mozilla.org/en-US/docs/Glossary/Parameter

A parameter is a named variable passed into a function. Parameter variables are used to import arguments into functions.

Note the difference between parameters and arguments:

  • Function parameters are the names listed in the function's definition.
  • Function arguments are the real values passed to the function.
  • Parameters are initialized to the values of the arguments supplied.

See also:

j08691
  • 204,283
  • 31
  • 260
  • 272
1

Yes, the explanations are correct but not complete. There is a lot more going on internally regarding them both, but the basic definitions are correct.

The parameters are the aliases for the values(arguments) passed to the function.

Arguments are the actual values that are passed to the function.

function f(a) => //a is a parameter
{}


f(5) => //5 is an argument.
ellipsis
  • 12,049
  • 2
  • 17
  • 33