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 trialDevon Handy
10,000 PointsWhat is the purpose of the "e" in the mousedown and mousemove functions? Is it a variable? A name?
$canvas.mousedown(function(e){
lastEvent = e;
mouseDown = true;
Why does it need the "e"? Where else would I need use syntax like this? How does it work? Will I ever stop asking questions? ;)
2 Answers
Dino Paškvan
Courses Plus Student 44,108 Pointse
is the event object. When you're dealing with event handlers, you write a function that gets called every time an event is triggered (mouse movement, mouse click, key press...).
That function gets passed an event object as a parameter. You usually call it event
, evt
, or just e
.
The event object allows you to access the event interface, to find out what type of event it was exactly, to prevent the default behavior of the event and so on.
davidschreiter
15,005 PointsIt's a character from the show entourage i do believe.
Johnny Garces
Courses Plus Student 8,551 Pointsfunny but useless. please stick to comedy outside of this forum.
davidschreiter
15,005 PointsI only have time for one chore, Tend the garden or clean the gutters. Should I choose the farmer or the ladder?
Don't rain on my parade, bro.
Jason S
16,247 PointsJason S
16,247 PointsI have a question about this too. What's the difference between an event and event handler and event interface , and why does mouseup not have the e? also when we write canvas.mousedown.mouseup is that the same as canvas.mousedown; canvas.mouseup?