Difference Between an Argument and a Parameter

If this post helps you, click an ad

It is very common in the programming world for the terms argument and parameter to be used to convey the same meaning. Technically, however, there is a distinct difference between the two.

When a function is defined, the expected variables are listed in parentheses. These are parameters.

For example:

function GetSquarePerimeter(sideLength)
{
return 4*sideLength;
}

In the preceding example, sideLength is a parameter of the Square function.

When a function is called, there is a list of variables that are passed to the function. The evaluation of these variables results in values that are passed to the function. These are arguments.

For example:

var intSideLength = 4;
var intPerimeter = GetSquarePerimeter(intSideLength);

At runtime, when the intSideLength variable is evaluated to 4, it is an argument to the GetSquarePerimeter function call.

Tags: ,

Leave a Reply