xxxxxxxxxx
function myFunction(paramOne, paramTwo){
//paramOne and paramTwo above are parameters
//do something here
return paramOne + paramTwo
}
myFunction(1,2) // 1 & 2 are arguments
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
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
function addTwoNumbers(num1, num2) { // "num1" and "num2" are parameters
return num1 + num2;
}
const a = 7;
addTwoNumbers(4, a) // "4" and "a" are arguments
xxxxxxxxxx
function createMenu({ title, body, buttonText, cancellable }) {
// ...
}
createMenu({
title: "Foo",
body: "Bar",
buttonText: "Baz",
cancellable: true
});
xxxxxxxxxx
Parameter is the variable in the declaration of the function.
Argument is the actual value of this variable that gets passed to the function.
xxxxxxxxxx
// Define a method with two parameters
int Sum(int num1, int num2)
{
return num1 + num2;
}
// Call the method using two arguments
var ret = Sum(2, 3);