dom events Flashcards

1
Q

What is the purpose of events and event handling?

A

to react to changes on the page and run code based on user input/interaction

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Are all possible parameters required to use a JavaScript method or function?

A

no

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What method of element objects lets you set up a function to be called when a specific type of event occurs?

A

addEventListener(‘event’, callbackFunction)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is a callback function?

A

a function that is passed as an argument to another function, and called by an event or something else later

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What object is passed into an event listener callback when the event fires?

A

event

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the event.target? If you weren’t sure, how would you check? Where could you get more information about it?

A

the element that triggered the event. console.log it!

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the difference between these two snippets of code?

element. addEventListener(‘click’, handleClick)
element. addEventListener(‘click’, handleClick())

A

the second one is passing a function CALL, not just the function. This callback will run prematurely

How well did you know this?
1
Not at all
2
3
4
5
Perfectly