⊗jsrtPmFcEOP 36 of 112 menu

Event object when passing parameters

Let's say we have some function func that we want to use as an event handler. Let's say this function takes some parameter:

function func(arg) { console.log(arg); }

Let's use this function as a handler by passing it a parameter:

function App() { function func(arg) { console.log(arg); } return <div> <button onClick={() => func('eee')}>act</button> </div>; }

Now, let's say that in addition to the parameter, we want to get the Event object in our function. To do this, we need to do the following:

function App() { function func(arg, event) { console.log(arg, event); } return <div> <button onClick={event => func('eee', event)}>act</button> </div>; }

Please tell me how the given code works.

Rework the given code so that the function takes two parameters.

Modify the previous task so that the event object is passed as the first parameter of the function, rather than the last.

Modify the previous task so that the event object is passed as the second parameter of the function, located between the first and third parameters.

enru