xxxxxxxxxx
function addTwoNumbers(num1, num2) { // "num1" and "num2" are parameters
return num1 + num2;
}
const a = 7;
addTwoNumbers(4, a) // "4" and "a" are arguments
xxxxxxxxxx
* Parameter - is the variable listed inside the parentheses
in the function definition.
* Argument - is the value that is sent to the function when it is called.
xxxxxxxxxx
def add(*numbers): # numbers = Parameter
retutn sum(numbers)
print(add(1, 2, 3)) # 1, 2, 3 = Arguements
xxxxxxxxxx
function test( a, b, c ) { // a, b, and c are the parameters
// code
};
test( 1, 2, 3 ); // 1, 2, and 3 are the arguments
xxxxxxxxxx
function example(parameter) {
console.log(parameter); // Output = foo
}
const argument = 'foo';
example(argument);
xxxxxxxxxx
In other words, to put these terms straight:
A parameter is the variable listed inside the parentheses in the function
declaration (it’s a declaration time term).
An argument is the value that is passed to the function when it is
called (it’s a call time term).
xxxxxxxxxx
Function parameters are the names listed in the function's definition.
Function arguments are the real values passed during function's calling.
xxxxxxxxxx
int main () {
int x = 5;
int y = 4;
sum(x, y); // **x and y are arguments**
}
int sum(int one, int two) { // **one and two are parameters**
return one + two;
}
xxxxxxxxxx
public void MyMethod(string myParam) { }
string myArg1 = "this is my argument";
myClass.MyMethod(myArg1);