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

what 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
Jesus Mendoza
23,289 Points

Hey 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!

I 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

Thank you guys for the answers. It's all clear now. :)