Submodule 12.1: JavaScript Functions

  • What are functions?
  • Parameters and Arguments
  • Return

Parameters and Arguments

You will often find the terms argument and parameter to be used interchangeably. 

However, here we will try to explain their difference.

When we declare a function, the text inside the parenthesis is called parameter.

A function can have one or more parameters.

Example: Function myFuncname (myParameter1, myParameter2){}

Inside the function, the parameters behave as local variables. All the usual variable rules apply to these variables.

In order for a function to be run, we have to call it. To call a function containing a parameter we write:

myFuncname (myArgument1, myArgument2);

In this case, the text inside the parenthesis is called argument instead of a parameter. 

Arguments are the actual values that will be passed into the function.


Follow the next link. Right-click, select inspect and click the "Sources" tab. Next, click the HTML file to see the code:

  Parameters and arguemnts