Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript Treehouse Club - MASH MASH - JavaScript Handle Submission and Event Handler Functions

Kegan Windle
Kegan Windle
2,217 Points

What is the difference between a parameter and a class?

I feel like I should have gotten this earlier.

2 Answers

Gyorgy Andorka
Gyorgy Andorka
13,811 Points

A class is kinda like a "blueprint" of an object, which is data stored in variables ("state") and functions/methods ("behaviour") encapsulated in a "box".

A function is an block of executable code (doing some specific task) packaged together, making it reusable. A "method" is a function which belongs to a class.

When you define a function, you can declare parameters inside the braces after the function name, which are variables reachable/usable inside your function. When you actually call the function, you give it "arguments", i.e. actual values to be assigned to those parameter variables.

function add(a, b) {  // a, b are parameter variables
  return a + b; 

// using the above defined function
console.log(add(1, 2))  // 1, 2 are argument values

A parameter is the argument that is passed into a function, while a class is a stand-alone object with behaviors and attributes..

For example: class Great { methods here }
While parameters are the arguments that a function takes.

Function example: function methodname(parameter name){ }