-1

I've see that you can do (e) -> {...} or (event) -> {...} as an input,

But I've also heard you can use any variable for event information like "a", "b", or anything like that. ex. (a) -> {...}

I was under the assumption "e" and "event" were unique, but it sounds like that's not the case from what I've read.

So my question is if I do (a) -> {...} how does the function know "a" contains information about the event? (And why would "a" have information about the event anyway, without being defined or something?)

Thanks, Will

willmhunt1
  • 47
  • 1
  • 4
  • Within certain contexts, the first parameter is _by default_ the event object. And it does not matter whether you name it e, ev, event, a, b, someOtherName, etc - it will contain the event-object. Please [check this](https://stackoverflow.com/a/35936912/13658816) to read a lot more. – jsN00b Mar 13 '22 at 18:16

1 Answers1

1

Values are assigned to function arguments, when the function is called, in order. The names you give you them inside the function are irrelevant and unknowable to anything outside the function.

const a = (one, two) => console.log(one, two);
const b = (two, one) => console.log(one, two);

a(1,2);
b(1,2);

The event object is simply passed as the first argument to the function when it is called.

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335