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 trialjlampstack
23,932 Points$(event.target) Vs. $(this)
I'm not understanding the difference. They seem to do the same thing?
1 Answer
Steven Parker
231,261 PointsIn an event handler, they are often the same thing. If you define an event handler with a conventional function expression, the system will set "this" to the target of the event object.
But if you were to define your event handler using an arrow function, the value of "this" would reflect the execution context.
jlampstack
23,932 Pointsjlampstack
23,932 PointsThanks Steven Parker .... What do you mean by reflect the execution context?
Steven Parker
231,261 PointsSteven Parker
231,261 PointsThe "execution context" is where the in the code the definition occurred. See the MDN page for an example.