So a quick question

Are arguments and parameters are same in a function? If they are not, what’s the difference? Thanks!!!

Although these two terms are sometimes used interchangeably, they are not the same.

A parameter is one of the variables in a function. And when a method is called, the arguments are the data you pass into the method’s parameters.

When the function is called with add(2, 3) the arguments 2 and 3 are assigned to x and y, respectively. This means that in the function, x will be replaced with 2 and y will be replaced with 3.

If the function is called with a different argument, the same applies. Parameters are like placeholders for function arguments.

1 Like

Parameter is like a variable name that you define in the function’s declaration or definition. It acts as a placeholder for the value that will be passed into the function when it is called.
An argument is the actual value that you pass to the function when you call it. This value is then assigned to the corresponding parameter within the function’s scope.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.