DOM Events Flashcards
Why do we log things to the console?
To check data (values of variables) and to verify if the codes are working correctly (double check functionality).
Logging things to console = developers way for verification.
What do [ ] square brackets mean in function and method syntax documentation?
It means that it’s optional.
What method of element objects lets you set up a function to be called when a specific type of event occurs?
addEventListener( ) method
What is the difference between these two snippets of code?
element. addEventListener(‘click’, handleClick)
element. addEventListener(‘click’, handleClick())
1 ) add.EventListener will receive the arguments: string ‘click’ and a function definition for handleClick.
2) add.EventListener will receive the arguments: string ‘click’ and the return value from handleClick.
What is the purpose of events and event handling?
Without events, the page would be static. Events make it possible for things to occur in the browser. Event handling makes it possible for us to respond to an event.
What is a callback function?
A function named that can be passed through to be used somewhere else.
What object is passed into an event listener when the event fires?
An object with all the information about the event.
What is the event.target? If you weren’t sure, how would you check? Where could you get more information about it?
Event.target is a property which holds a reference to the html element that triggers the event firing in the first place.
Look up on MDN documentation for more information.