DEV Community

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

Posted on β€’ Edited on

64 15

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 :)

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free β†’