DOM-events Flashcards
Why do we log things to the console?
To see what’s going on without having to find the issue later.
What is the purpose of events and event handling?
They notify code of interesting changes.
Are all possible parameters required to use a JavaScript method or function?
Not sure.
What method of element objects lets you set up a function to be called when a specific type of event occurs?
addEventListener
What is a callback function?
A function passed into another function as an argument.
What object is passed into an event listener callback when the event fires?
The event object
What is the event.target? If you weren’t sure, how would you check? Where could you get more information about it?
The target event property returns the element that triggered the event. Where the interaction took place.
What is the difference between these two snippets of code?
element. addEventListener(‘click’, handleClick)
element. addEventListener(‘click’, handleClick())
In the 1st, the 2nd argument is the function named handleClick, in the 2nd argument, the 2nd argument is being called. We’re passing a function definition.