Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript JavaScript and the DOM (Retiring) Responding to User Interaction Listening for Events with addEventListener()

In "addEventListener('mouseover', (), why are the parentheses empty before the arrow function?

Sorry in advance if this is a ridiculous question but I've understood everything up until now. I did the practice on arrow functions and I thought I understood them but I guess I am struggling to apply their use to methods, particularly the addEventListener method. So what are the first empty set of () supposed to mean? Is this what Guil was referring to as an anonymous function? Thanks in advance.

2 Answers

Steven Parker
Steven Parker
210,475 Points

The empty parentheses indicate that the function takes no argument(s), and are required by the syntax.

Arrow function expressions are also anonymous, whether they take arguments or not. That just means they don't have a specific name.

This made more sense once I re-watched the video about events. Thank you.