JavaScript Functions: Parameters and Arguments

Profile picture for user arilio666

In javascript, there's a usual confusion between what parameters are and what arguments are in a javascript function.

  • Parameters are the names given within the function call we can even call it variables it is always up to us what we name our parameters.
  • Arguments are values used to invoke the function created with the parameter and pass in the respective values as arguments inside that function parameter names and invoke the return of the function block.

Syntax

function name(parameters)
{
    //return
}

name(arguments)

Example

function covidVaccine(itemName, amount)
{
    console.log('Things needed for vaccination: ' +itemName, amount)
}

covidVaccine('CoviShield', '2 Doses')

Here is a simple code that can help you identify what the parameter value is and how it can be named with your choice.
And the arguments/values which are passed for the respective parameters and invoked the function.