dom-events Flashcards
Why do we log things to the console?
test and debugg our code
What is the purpose of events and event handling?
to allow users to interact with the page and have that result in the page changing
What do [] square brackets mean in function and method syntax documentation?
indicates optional
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?
one that will be called by another function or object etc
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?
reference to the object onto which the event was dispatched. on mdn
What is the difference between these two snippets of code?
element. addEventListener(‘click’, handleClick)
element. addEventListener(‘click’, handleClick())
the first one is a callback function and second one is calling the function. the second one immediately calls the function