Parameters and Arguments: What's the Difference?

Oftentimes, parameters and arguments are used interchangeably in software development/programming lingo, but what's the actual difference?

Well, essentially, it's this: you add parameters to a function when you're defining it, and you add arguments to a function when you're calling it.

For example, if we have a small function that says hello to a user like so:

  function sayHello(firstName, lastName) {
    console.log(`Hi there, ${firstName} ${lastName}!`)
}

sayHello('Debbie', 'Otua')

The "firstName" & "lastName" in the first line are the parameters that this function needs to be defined. However, the strings inside the function in the last line, "Debbie" & "Otua" are the arguments that the function needs to run.

If we were to just call the function without passing arguments, we'll get something like: Hi there, undefined undefined! instead. We would also get an error if we were to pass arguments without stating parameters first.

Hopefully, that helps to clarify the difference between these two. Thank you for reading!