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 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){ }