Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

Greg Schudel
Greg Schudel
4,090 Points

general question: what is the difference between a argument and a parameter?

In javscript, what is the difference between an argument and a parameter:

function(if this is the parameter) {

is what is returned/called here the argument?

}

1 Answer

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! Some programmers use "argument" and "parameter" interchangeably. However, I'm not one of those. Semantics would dictate that the argument is what we're sending into the function and the parameter is defined in the definition of the function. The parameter takes the argument. Let me give an example:

function sayHi(firstName) {
  console.log("Hi there, " + firstName);
}

sayHi("Greg");

In this instance firstName is the parameter. It is accepting the data coming in. The argument is "Greg". It is the data being sent to the function that will then be held by firstName. You can think of a parameter as a local variable declaration for the lifetime of the function's execution.

Hope this helps! :sparkles: