In which situations should we say a function has a parameter or a argument?

Hello everyone,

For a more rigorous comunication , while using functions , what really is the difference between parameter and argument?

1 Like

according to the documentation:

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Functions

A function definition (also called a function declaration , or function statement ) consists of the function keyword, followed by:

  • The name of the function.
  • A list of parameters to the function, enclosed in parentheses and separated by commas.
  • The JavaScript statements that define the function, enclosed in curly brackets, {...} .

Defining a function does not execute it. Defining it simply names the function and specifies what to do when the function is called.

Calling the function actually performs the specified actions with the indicated parameters. For example, if you define the function square , you could call it as follows:

square(5);

The preceding statement calls the function with an argument of 5 . The function executes its statements and returns the value 25 .

so parameters is when we define a function, then when you call a function you provide arguments for the parameters.

8 Likes

Quite simply, parameters are variables, arguments are values. Parameters don’t have a type, but argument values do.

11 Likes