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:
jsxfunction func(arg) {
console.log(arg);
}
Let's use this function as a handler by passing it a parameter:
jsxfunction 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:
jsxfunction App() {
function func(arg, event) {
console.log(arg, event);
}
return <div>
<button onClick={event => func('eee', event)}>act</button>
</div>;
}
Задание 1
Please tell me how the given code works.
Задание 2
Rework the given code so that the function takes two parameters.
Задание 3
Modify the previous task so that the event object is passed as the first parameter of the function, rather than the last.
Задание 4
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.