dom-events Flashcards
Why do we log things to the console?
- verify what the code is doing
2. debugging
What is the purpose of events and event handling?
An event indicates that an action is taking place. The event handler deals with the event.
Are all possible parameters required to use a JavaScript method or function?
-no
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 callback function is a function passed into another function as an argument, which is then invoked inside the outer function to complete some kind of routine or action.
What object is passed into an event listener callback when the event fires?
-event
What is the event.target? If you weren’t sure, how would you check? Where could you get more information about it?
- It is a property of an event which is a reference to the element upon which the event was fired.
- In the listener parameter, console.log(event.target)
- When the event is fired, check the console to get the details of MDN.
What is the difference between these two snippets of code?
The first will call the function when the event happens. The second will call the function when the page loads.