DEV Community

Cover image for Arguments and Parameters - do you know the difference?
Benjamin Mock
Benjamin Mock

Posted on • Updated on

Arguments and Parameters - do you know the difference?

When talking about code, arguments and parameters are oftentimes mixed up. So let's clarify that once and for all!

Let's have a look at a simple JavaScript function:

function log(a, b) {
  // do something
}

const myString = "codesnacks"

log(10, myString)

So we have a log function, that takes two parameters, a and b. And we're calling it with the two arguments 10 and myString.

The parameters a and b are potential values, 10 and myString, the arguments, are actual values.

It's relatively easy to remember if you keep the following in mind:

Parameters are Placeholders.
Arguments are Actual values.

Top comments (6)

Collapse
 
bbarbour profile image
Brian Barbour

I did not know this! I thought they were synonyms for each other.

Collapse
 
mariewie profile image
MarieWie

That is a really nifty mnemonic for a difference I was not quite clear on yet. Thank you!

Collapse
 
azzamaurice profile image
Aaron Maurice

This is great!
I knew which is which, but a mnemonic is super handy!

Collapse
 
vinceramces profile image
Vince Ramces Oliveros

There are some languages that offer Pass By Value and Pass by Reference

most programming languages are Pass By Value

Collapse
 
imshivanshpatel profile image
SHIVANSH PATEL

Thanks buddy

Collapse
 
deveshlashkari profile image
Devesh Lashkari

I never thought about this. Thanks :)