They both are function calls. The difference is that in first call, you use an arrow function with the event parameter (e).
Arrow function
(param1, param2, …, paramN) => { statements }
As stated in the documentation
An arrow function does not create it's own this context, rather it captures the this value of the enclosing context
So, I assume you are trying to get the data attribute using the this
keyword
$(this).attr('data-test')
but, in arrow function, the this
refers to the object of the enclosing context, not to the specific object.
The second one is a classic function call and this
refers to the clicked element, so here you can successfully get the 'data-test' attribute.
EXAMPLE
Check this live example
In both buttons, the this object is writen in the console.log. Using the normal function the console outputs teh clicked element (the button) but, using the arrow function the console outputs the window object.