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

Why we use event.target instead of e.target?

'E' is the first parameter in function (listener). Why we use event.target instead of e.target?

Steven Parker
Steven Parker
243,095 Points

What you are describing sounds like an error. Can you provide a link to where you are seeing this?

2 Answers

Steven Parker
Steven Parker
243,095 Points

That's a mistake in the video.

It probably slipped by because the code works anyway. That's because some browsers (and clearly the one being used) will make the current event object available in the global window.event, which can be referenced simply as "event" if the name has not been reused.

But this behavior is not supported by all browsers, not guaranteed, and should definitely not be relied on. The passed-in event object should always be used instead.

Good catch! :+1: You might want to report this as a bug using the Support page. It may even get you a special "Exterminator" badge. :beetle: