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 trialAlina Antemir
10,185 Pointswhat does e from (e) => stands for?
Hi,
I don't understand how the function (e) => works. What is 'e' ?
Can you please explain?
Thank you, Alina
3 Answers
Jesus Mendoza
23,289 PointsHey Alina,
Whenever you add an event listener to an element you need to pass an event handler (callback) right?
element.addEventListener('click', (e) => {
console.log(e);
});
When the event is fired, that callback function is called and recieves one argument (e), that parameter contains all all the information of the event that just happened. If you log (e) you will see all that information.
Have a nice day!
Alexander Davison
65,469 PointsI recommend watching this workshop to get an idea of Arrow-function syntax. It is a pretty handy tool just to create a function with less code.
The basic idea is that this:
(e) => {
}
Is the same as this:
function (e) {
}
I hope this helps. ~Alex
Alina Antemir
10,185 PointsThank you guys for the answers. It's all clear now. :)