Say we want to take two actions simultaneously on a button click. The old school way of doing the same is by calling two functions inside
onClick handler separated by a semicolon or wrapping two functions inside another function.
The above approach works, however, there is another cleaner approach using event listeners. So, instead of calling inline functions, we should use event listeners on button click.
Let’s see it in action.