JavaScript Functions: Parameters and Arguments

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.

Fri, 10/22/2021 - 08:23

Authored by

Ashwin is working with iVagus as a Technical Lead. He has experience in various technologies like Cypress, JavaScript, TypeScript, Rest Assured, Selenium, Cucumber, and Java.
Tags