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.