dom events Flashcards
Why do we log things to the console?
To observe things
What is the purpose of events and event handling?
To control behavior for certain events
Are all possible parameters required to use a JavaScript method or function?
No, there are some functions that have optional parameters
What method of element objects lets you set up a function to be called when a specific type of event occurs?
myElement.addEventListener()
What is a callback function?
a function taken as an argument of another function and is invoked inside that function. syntax is:
callback(params);
where callback is the literal word being used
What object is passed into an event listener callback when the event fires?
the object receiving the notification when the even occurs
What is the event.target? If you weren’t sure, how would you check? Where could you get more information about it?
it is the property of the event that is the element being interacted with
you can check with console.log(event.target);
console
What is the difference between these two snippets of code?
element. addEventListener(‘click’, handleClick);
element. addEventListener(‘click’, handleClick());
the first will wait for the notification to run
the second will immediately run