Skip to main content

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.

Tags
Submitted by arilio666 on October 22, 2021

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.

About

At ProgramsBuzz, you can learn, share and grow with millions of techie around the world from different domain like Data Science, Software Development, QA and Digital Marketing. You can ask doubt and get the answer for your queries from our experts.