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 jQuery Basics (2014) Creating a Simple Drawing Application Perform: Part 5

why the dots between mouseMove(), mouseUP(), mouseDown()...

why is it mouseDown().mouseMove().mouseUp() ? why theses functions are not separated?

3 Answers

Hi Ravit,

This is a syntax called method chaining. Method chaining is used to invoke multiple methods at once. Gregory Schier wrote a really nice article about this on his blog, see here. You can also find many other resources regarding method chaining via Google.

Pavle Lucic
Pavle Lucic
10,801 Points

It is called method chaining, where a method returns the object which it called it.

the order should matter, right?

Pavle Lucic
Pavle Lucic
10,801 Points

In this example, answer is no.

.mouseup( handler )
handler
Type: Function( Event eventObject )
A function to execute each time the event is triggered.

This is from jquery docs.

Important part is handler. By that I mean what function will execute on mouse up.