DOM-events Flashcards
Why do we log things to the console?
For debugging and and inspecting our variables in the browser.
To check our data along the way.
What is the purpose of events and event handling?
Events can trigger a particular function or code. Event handling (how code responds to users) updates the content of the web page
What do[]square brackets mean in function and method syntax documentation?
That they are optional.
What method of element objects lets you set up a function to be called when a specific type of event occurs?
event listener
addEventlistener
What is a callback function?
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?
function Object
What is theevent.target? If you weren’t sure, how would you check? Where could you get more information about it?
Look it up on the MDN documentation.
Thetargetproperty of theEventinterface is a reference to the object onto which the event was dispatched.. It returns the element that triggered the event.
What is the difference between these two snippets of code?
element.addEventListener(‘click’, handleClick) element.addEventListener(‘click’, handleClick())
The second one indicates that the function should run as the page loads (rather than when the even fires).