Let’s look at a (rather contrived) function that adds two numbers together and returns the result.
add() function above, the parameters are
num2. They’re the names listed in the function declaration. You could give a parameter any arbitrary name, but a descriptive name is best. They’re like variables in this way. We’ve used
num2 here because we’re expecting two numbers to be passed in when the function is called.
Let’s call our
add() function and log the result to the console.
In the example above, the integers
5 are our arguments. They’re the actual values we pass into the function. Our parameters (
num2) are initialized with these values. In other words: when we call the function with the values
num1 parameter refers to
3, and the
num2 parameter refers to
Does it matter?