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


Methods ()


Any tips on working out what goes between the () in a method?

The vids so far tell you what to put in them, but when i check W3c to read more about a method its not always clear on what it can take between the ()

Any tips?

4 Answers

What you are asking about are parameters that a function/method can take. There is no sure way to guess what parameters (if any) a function will take. You will have to take a look at the documentation for a particular function to see what parameters it takes.

Thankfully, when it comes to built-in objects/functions/methods, Mozilla provides great documentation for everything you might need, including what parameters functions take.

With enough practice, you'll soon know by heart what parameters commonly-used functions take.

Oh i see that link makes it nice and clear.

Can a method be passed data then?

I was editing my post and my reply got out of order..

Oh i see that link makes it nice and clear.

Can a method be passed data then?

A function is a re-usable piece of code that turns input(s) into an output, or does something (also called a side effect). A method is a function that has been defined on a particular object.

In JavaScript the distinction is somewhat moot as all built-in functions are defined on objects, if none other, then the global window object.

Yes, a method acts the same way as a function. The only distinction is that you'd call a function like this: myFunction(someParameter); and a method like this: someObject.myMethod(someParameter);.

thanks for clearing that up for me